7
$\begingroup$

I'm producing a graphic (sorry for not posting the code but it's quite disordered (see edit below)) and would like to export it as a vector image. For some reason the PDF (below left) does not look very much like the one I see in the notebook (right) (only corrected when exporting to .png or .jpg.)

enter image description here enter image description here

I tried to search in previous post but up to now, despite many related troubles, I have not found a quick solution.

(I'm working with Mathematica 12.3.1.0 on MW 64-bit platform)

EDIT The following is a simplified version of the drawing but with exactly the same issue.

\[CapitalOmega] = Disk[{0, 0}];
circ = ParametricPlot[{x, y}, {x, y} \[Element] \[CapitalOmega], AspectRatio -> 1, PlotStyle -> Gray, BoundaryStyle -> Black]

so when I use

Export["path\\gra.pdf", circ, "PDF"]

I get the "dark" picture as before (or as shown below), instead of the "light" one that I see in the notebook.

enter image description hereenter image description here

$\endgroup$
7
  • 2
    $\begingroup$ I don't know how you think we could possibly help you without the code that generate that image, as well as mention of your version of Mathematica and of your operating system. $\endgroup$
    – MarcoB
    Jul 10, 2022 at 5:18
  • $\begingroup$ @MarcoB True. As for the version, it is 12.3.1.0. The code is really messy, so I'll try to paste it if no generic answer is eventually given, but I'd prefer to avoid it. Let me just mention that I've gotten similar results when exporting several kinds of plots in PDF format. Thank you. $\endgroup$ Jul 10, 2022 at 5:34
  • 1
    $\begingroup$ Please prepare a minimal working example reproducing this behavior. If not, the question will be closed. $\endgroup$ Jul 10, 2022 at 5:48
  • 1
    $\begingroup$ Confirm it (both pdf and eps) in 13.1 on Windows 10. $\endgroup$
    – user64494
    Jul 10, 2022 at 6:47
  • 3
    $\begingroup$ @DanielCastro See here $\endgroup$
    – martin
    Jul 10, 2022 at 7:46

1 Answer 1

5
$\begingroup$

I reproduce the bug with versions 12.3.1 and 13.1.0 on Windows 10 x64. Please report it to the support.

Here is a fix:

circFixed = 
 circ /. Polygon[pts : {{__Integer} ..}] :> FilledCurve[List /@ Thread[Line[pts]]]
Export["gra.pdf", circFixed] // SystemOpen

screenshot

Actually, we have two bugs here:

  1. Exporting Polygon primitive to PDF format results in addition of unwanted outline.

  2. Exporting of a group of FilledCurves (which is the most direct fix for the bug #1) to PDF format gives unwanted tiny white lines between them. This doesn't happen when we export them as one FilledCurve object using the multi-component single-segment syntax form of FilledCurve as recommended here. The latter approach is implemented in the fix I provided above. It works well in this concrete case. However, this solution isn't correct in the general case, because this syntax form will create holes where the components overlap, what we don't want because the multi-component syntax form of Polygon doesn't have this feature.

$\endgroup$

Your Answer

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

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