Group Abstract Group Abstract

Message Boards Message Boards

How to fit a Dataset output in a PDF file?

Posted 4 years ago

I need help regarding the following problem:

In my notebook I am creating several datasets and I show the output, as you can see in the following screenshot. mathematica notebook

I want to share the notebook in PDF format as well. When I make use of the "Save as" functionality to create a PDF, I get the following result. pdf file

What can I do to have the full dataset output on the PDF page?

POSTED BY: Jürgen Kanz
15 Replies

You might want to try ItemSize option to resize all columns. For example:

Dataset[{
   <|"a" -> 1, "b" -> "x", "c" -> {1}|>,
   <|"a" -> 2, "b" -> "y", "c" -> {2, 3}|>,
   <|"a" -> 3, "b" -> "z", "c" -> {3}|>,
   <|"a" -> 4, "b" -> "x", "c" -> {4, 5}|>,
   <|"a" -> 5, "b" -> "y", "c" -> {5, 6, 7}|>,
   <|"a" -> 6, "b" -> "z", "c" -> {}|>
    },
    ItemSize->10
]

enter image description here

POSTED BY: Sa'di Altamimi

Hi all,

if it is just about the Dataset only - how about displaying the Dataset in all its beauty (using the option MaxItems -> {All, All}) and then simply export it as PDF?

(* creating "large" test-Dataset: *)
{dimx, dimy} = {25, 30};
rowKeys = RandomWord[dimy];
colKeys = RandomWord[dimx];
dataset = 
 Dataset[AssociationThread[rowKeys, 
   Table[AssociationThread[colKeys, RandomReal[{0, 1}, dimx]], dimy]],
   MaxItems -> {All, All}]
(* ... and exporting it: *)
Export["ds.pdf", dataset]
POSTED BY: Henrik Schachner
POSTED BY: Jürgen Kanz
POSTED BY: Henrik Schachner

You are always welcome.

POSTED BY: Jürgen Kanz

Glad I could help.

I use the same technique to export other graphics for import into other programs. For example, if you export plots with huge amounts of points and import them into Microsoft Word, you can slow Word and actually crash it. Every single point is exported as a separate line even if not visible. If you rasterize and export as tiff or jpg or pdf, everything is fine and you can make sure you get great resolution.

Regards

Neil

POSTED BY: Neil Singer

Jürgen,

I recommend rasterizing the dataset in Mathematica and controlling the output. I started with a dummy dataset.

dataset = Dataset[{
    <| "min" -> <|"aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "xxxxx", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "f" -> RandomReal[], "g" -> RandomReal[]|>|>,
    <| "max" -> <|"aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "yyyyy", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "f" -> RandomReal[], 
       "g" -> RandomReal[]|>|>,
    <| "median" -> <|"aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "zzzzz", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "f" -> RandomReal[], 
       "g" -> RandomReal[]|>|>,
    <| "SDSDSDSDSDSDSDSDSDSDSDSDSDSDSD" -> <|
       "aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "xxxxx", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "f" -> RandomReal[], 
       "g" -> RandomReal[]|>|>,
    <| "var" -> <|"aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "yyyyy", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "f" -> RandomReal[], 
       "g" -> RandomReal[]|>|>,
    <| "max" -> <|"aaaaaaaaaaaaaaaaaaaaa" -> RandomReal[], 
       "baaaaaaaaaaaaaaaaaaaa" -> "zzzzz", 
       "caaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "e" -> RandomReal[], 
       "daaaaaaaaaaaaaaaaaaaa" -> RandomReal[], "f" -> RandomReal[], 
       "g" -> RandomReal[]|>|>}];

Rasterize the dataset to whatever resolution and ultimate size you want.

dataRasterized = 
 Rasterize[dataset, ImageSize -> 1000, ImageResolution -> 300]

and create the PDF file from that:

Export["mypdf.pdf", dataRasterized]

Regards,

Neil

POSTED BY: Neil Singer

Neil,

Great, it works! Thank you!

I hope the Wolfram Team will come up with an automated concept in 12.3?

POSTED BY: Jürgen Kanz
Posted 4 years ago
POSTED BY: Rohit Namjoshi
POSTED BY: Jürgen Kanz
Posted 4 years ago
POSTED BY: Hans Milton

Good idea, Hans!

In my current case, it would solve the problems because I have only 6 to 7 data columns in my Dataset[]. If I would have more columns then I would go in trouble again. Please have a look at a modified dataset printed as PDF in Landscape mode. enter image description here

POSTED BY: Jürgen Kanz
Posted 4 years ago

When needed you can change to a larger paper size. For example A3:

enter image description here

POSTED BY: Hans Milton

Did you use Grid[] for the tables?

POSTED BY: Raspi Rascal

Yes, I have tried, but it does not solve the problem.

Thanks!

POSTED BY: Jürgen Kanz
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard