The code below plots and exports to a PDF file. As one can see, there is a clear difference between the plotted line thickness in the notebook and in the PDF snapshot.
d1 = Cos[x] + Cos[z] - 2; x0 = 0; z0 = \[Pi]/2;
SSregion[x_, z_] = d1^2 - 1 < 0; bleqn = d1^2 - 1 == 0;
twopts = {{x0, z0}, {x0, -z0}};
plotTP = {PointSize[0.03],
Point[twopts, VertexColors -> {Black, Black}]};
lines = {{0.4, 0.6}, {2.4, 0.6}};
thickness1 = 0.01; thickness2 = 0.01;
plotreg =
RegionPlot[SSregion[x, z], {x, -\[Pi], \[Pi]}, {z, -\[Pi], \[Pi]},
BoundaryStyle -> Directive[Thickness[thickness1], Dashed],
FrameLabel -> {"x", "z"}, FrameTicksStyle -> 18, LabelStyle -> 22,
Epilog -> {plotTP}, ImageSize -> 255];
plotreg =
Show[plotreg,
Graphics[{Black, Thickness[thickness1], Dashed, Line[lines]}]]
Export[FileNameJoin[{NotebookDirectory[], "Test.pdf"}], plotreg,
ImageResolution -> 300];
Several observations:
- There seems to be some threshold thickness between 0.01 and 0.011, where the PDF line thickness suddenly changes.
- Double the
imagesize
may occasionally get this issue away, but this is not what is wanted. For other reasons like file size and screen size, I need to keep such an image size. - Right-click the image and save it as PDF sometimes may get it right, but not a desired solution, either. For instance, sometimes I need to use
Grid
(rather thanGraphicsGrid
) for multiple figures, which does not accept such a workaround. - Tuning
ImageResolution
does not help. Removing this option sometimes may get it right, but in other more complicated plots this will make the PDF file outrageously large or just freeze the program.
Is there any remedy for this?