8
$\begingroup$

I have a figure (which is by combining different plots) that I generated using Grid[]. The problem is, I want to specify the ImageSize of this final figure. I am unable to do it in Grid[]. Therefore, I wanted to convert this Grid[] object to Graphics[] object so that I can save it as a PDF of desired ImageSize.

Note: I tried to save the output of Grid[] as PDF using Export[]. It works fine. However, when I set ImageSize in Export[], it seems to be ignored.

I tried

i=First@ImportString[ExportString[figure, "PDF"]];

But even this seems to lose clarity but this gives crispier image than Rasterize

Magnify[] seems to do what I want even if It doesn't convert the figure to graphics, I can change the resolution by trial and error. Not the best way to do it but gets the job done.

$\endgroup$
7
  • $\begingroup$ Have you tried Rasterize? reference.wolfram.com/mathematica/ref/Rasterize.html $\endgroup$
    – Jonie
    Commented Aug 1, 2013 at 23:59
  • $\begingroup$ that works but not as good as exporting the grid[] directly to output pdf which had size of 877X353 but much clearer than output of Rasterize[] which I had set to an ImageSize of 1000. I played around with RasterSize increasing it all the way to 15000. But doesn't seem to get better. Do you know what causes this loss of clarity? $\endgroup$
    – preeti
    Commented Aug 2, 2013 at 0:32
  • 3
    $\begingroup$ Why not use GraphicsGrid instead of Grid, it has a ImageSize option to set the overall size of the whole graphics grid. $\endgroup$ Commented Aug 2, 2013 at 4:32
  • 4
    $\begingroup$ Because GraphicsGrid resizes the individual components at its own will. I don't know how to prevent that. $\endgroup$
    – preeti
    Commented Aug 2, 2013 at 15:38
  • 2
    $\begingroup$ How about Magnify? $\endgroup$
    – David Park
    Commented Aug 2, 2013 at 23:49

1 Answer 1

2
$\begingroup$

I am still confused about this question. I am posting this just to understand better what is wrong again with using GraphicsGrid or Magnify as was suggested above? Here is just an example. Why this does not work? It is also easy to use ItemSize to control the size of each entry in the GraphicsGrid if needed.

SetDirectory[NotebookDirectory[]];
Manipulate[
 s = Which[method == "GraphicsGrid",
   GraphicsGrid[tbl, Frame -> All, Spacings -> {.5, .5},ImageSize -> n],
   method == "Magnify", Magnify[Grid[tbl, Frame -> All], n/500]
   ],

 {{n, 300, "how big?"}, 200, 1000, 10, Appearance -> "Labeled"},
 {{method, "GraphicsGrid"}, {"Magnify", "GraphicsGrid"}},
 Button["Export to PDF", Export["s.pdf", s]],
 Initialization :>
  (
   tbl = Table[ListPlot[RandomReal[{0, 1}, 10],Joined->True,ImageSize->100], {3}, {3}]
   )
 ]

Mathematica graphics

$\endgroup$
1
  • 1
    $\begingroup$ Magnify does work. With GraphicsGrid, I tried to play around with ItemSize. But I could not get it to do what I want. One main difference from your example is, I have one item spanning the whole row and two other items spanning the next row. The alignment is a problem. I cannot align each element differently as in case of grid. $\endgroup$
    – preeti
    Commented Aug 4, 2013 at 17:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.