0
$\begingroup$

I am trying to generate a figure produced by Graphics command and export it to a pdf file having a fixed width. I followed the answer in these links, 1 and 2. These two solutions worked well with Plot and ListPlot as they are mentioned. However, they could not work in the same way in case of Graphics. A sample code used for testing is:

pts = {{0, 0}, {0, 1}, {1, 1}, {1, 0}, {0, 0}};
pts1 = Table[i + {0.5, 0.5}, {i, pts}];
Show[Graphics[{Line[pts], Line[pts1]}],  ImageSize -> {9*72/2.54, Automatic}]
Export["test.pdf", %]

As mentioned in the comments, followed a slightly modified code as

 Graphics[{Line[pts], Line[pts1]}]
 Export["test1.pdf", Show[%, ImageSize -> {9*72/2.54, Automatic}]]

Both the pdf files have exactly the same sized images which is 11.5cm at 100% magnification!
In the case of Plot and other commands, the same Show and Export commands have one scaling factor and a different one for the Graphics function?

Using lower dimensions in the image size could result in the desired size one wants i.e. different scaling factors for different commands. But, How to understand this issue in a logical manner?

PS: I am working on Mathematica V 11.0.1.0

$\endgroup$
  • $\begingroup$ In your examples the finale size should be 9 cm, right? I got 9 cm exactly in both cases, MMA 12.0, measured in Adobe Acrobat with 100% magnification. $\endgroup$ – Alx Jul 26 '19 at 13:46
  • $\begingroup$ That's a surprise. It should be 9cm. Finally, I am using a factor to get the desired size. $\endgroup$ – Rajendra prasad Jul 26 '19 at 13:51
  • $\begingroup$ May it be that this is a property of the version 11? I cannot check, since have the version 12 only. However, should this be the case I can offer a simple workaround. Add formally a Plot function to the first position under Show shuch that it draws nothing. Like this: Show[{Plot[0, {x, 0, 1}, Axes -> None, PlotRange -> {{0, 1.7}, {0, 1.5}}, ImageSize -> {9*72/2.54, Automatic}], Graphics[{Line[pts], Line[pts1]}]}]. Then Show inherits the properties of Plot. $\endgroup$ – Alexei Boulbitch Jul 26 '19 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.