# Bug in Export of figures with PlotMarkers?

I am experiencing problems with exporting figures such as combinations of ContourPlot and ComplexListPlot. As an example, when zooming into the resulting pdf of the plot

Show[ComplexListPlot[{0.4 + 0.2 I},
PlotMarkers -> {{Graphics[Triangle[{{{0, 0}, {1, 1.6}, {2, 0}}}]],
0.03}}]]
Export["test.pdf", %];

this gives the following picture.

The top part is cut off for no apparent reason. When such PlotMarkers are combined with more complicated Figures, they get arbitrarily disfigured (ignore the gray strip):

This should depict a Triangle, and there are similar problems for simpler Graphics such as Rectangle or Disk. An alternative to PlotMarker is given in this answer, which for simple plots works but in combination with other plots shows similar effects. The result is not dependent on the way the Figure is saved (either with "Save Graphic as" or Export), and seems to be independent also on the file type. I am running Mathematica 12.3. Any help is much appreciated.

• One way around this is to Rasterize your graphic before exporting: Export["test.pdf",Rasterize[%, ImageSize -> Full]]; you can increase the resolution if necessary Jun 21, 2021 at 19:42
• Thank you, it works but unfortunately the image quality is significantly lower (even with increasing the ImageResolution). Perhaps you have other ideas? Jun 21, 2021 at 21:03
• Have you tried this? Export["test.pdf", Rasterize[%, ImageSize -> Full, ImageResolution -> 600]]; That created a very crisp image for me Jun 21, 2021 at 22:03
• Yes it does give a relatively sharp image, however with my plots the files get huge and take a long time to load in a PDF viewer. I am really trying to circumvent this if possible. Jun 21, 2021 at 22:26
• Have you tried constructing the polygons without using the built-in primitives? Jun 22, 2021 at 2:19

Basically you are facing the problem described here. The simplest workaround is to evaluate

SetOptions[$FrontEndSession, PrintingStyleEnvironment -> "Working"] before exporting. Now it works as expected: ComplexListPlot[{0.4 + 0.2 I}, PlotMarkers -> {{Graphics[Triangle[{{{0, 0}, {1, 1.6}, {2, 0}}}]], 0.03}}]; Export["test.pdf", %] // SystemOpen Note however that your plot marker is misplaced: Show[ComplexListPlot[{0.4 + 0.2 I}, PlotMarkers -> {{Graphics[Triangle[{{{0, 0}, {1, 1.6}, {2, 0}}}]], 0.2}}], ComplexListPlot[{0.4 + 0.2 I}, PlotStyle -> Red]] You see that the center of the triangle is misplaced. Here is a way to place your plot marker correctly: marker = Triangle[{{{0, 0}, {1, 1.6}, {2, 0}}}]; markerCentroid = RegionCentroid[marker]; markerBounds = RegionBounds[yourMarker]; markerPlotRange = Transpose[{markerCentroid - #, markerCentroid + #} &[ Max /@ Abs[markerBounds - markerCentroid]]]; pl = Show[ ComplexListPlot[{0.4 + 0.2 I}, PlotMarkers -> {{Graphics[marker, PlotRange -> markerPlotRange, PlotRangePadding -> 1], 0.5}}], ComplexListPlot[{0.4 + 0.2 I}, PlotStyle -> Red]] This plot will export correctly even with the default settings for PrintingStyleEnvironment: SetOptions[$FrontEndSession, PrintingStyleEnvironment -> Inherited]
Export["test.pdf", pl] // SystemOpen

Another method is to apply the AlignmentPoint option:

marker = Triangle[{{{0, 0}, {1, 1.6}, {2, 0}}}];
markerCentroid = RegionCentroid[marker];
Show[ComplexListPlot[{0.4 + 0.2 I},
PlotMarkers -> {{Graphics[marker, AlignmentPoint -> markerCentroid,