4
$\begingroup$

This problem does not exist in 13.2.1 anymore


I often need to export some svg with mma, but RegionPlot's diagrams will have some extra mesh after exporting SVG:

p = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}];
Export["p.svg", p]

enter image description here

Not only does this make SVG very ugly, but it can lead to very large files. And is this a bug of MMA?

$\endgroup$
10
  • $\begingroup$ p = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}, PlotStyle -> Cyan]; Export["p.svg", p] $\endgroup$
    – cvgmt
    Jan 7, 2022 at 10:59
  • $\begingroup$ @cvgmt As the file size is large than before, I think the color just covers those mesh, which actually exists. $\endgroup$
    – yode
    Jan 7, 2022 at 11:08
  • 3
    $\begingroup$ Also look at 257039. $\endgroup$
    – Syed
    Jan 7, 2022 at 11:31
  • $\begingroup$ Yep, fixed in 13.2.1. Well, there are still some invisible lines... $\endgroup$ Feb 20, 2023 at 3:50
  • $\begingroup$ @ВалерийЗаподовников Invisible ? $\endgroup$
    – yode
    Feb 20, 2023 at 4:01

2 Answers 2

6
$\begingroup$
p = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}, 
   PlotStyle -> {EdgeForm[]}];
Export["p.svg", p]

enter image description here

pp= RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}, 
   PlotStyle -> {EdgeForm[], FaceForm[Green]}, 
   BoundaryStyle -> None];
Export["pp.svg", pp]

enter image description here

ppp = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}, 
   PlotStyle -> {EdgeForm[], FaceForm[None]}, BoundaryStyle -> Red];
Export["ppp.svg", ppp]

enter image description here

$\endgroup$
2
  • $\begingroup$ I thought the filesize would be smaller without the grid, but it still looks the same. And As far as I know, MMA doesn't have a parameter for resizing SVG filesize? $\endgroup$
    – yode
    Jan 7, 2022 at 11:57
  • $\begingroup$ They are smaller in the last case for ppp.svg, for pdf and for svg, cause in acrobat white is just white of the background. $\endgroup$ Feb 20, 2023 at 10:14
3
$\begingroup$

This code almost solves my problem, which will export very small and meshless SVG file, but the background is not transparent. I don't know how to export an SVG file with the transparent background..

p = RegionPlot[x^2 + y^3 < 2, {x, -2, 2}, {y, -2, 2}];
BoundaryDiscretizeGraphics[p, Frame -> True];
Export["p.svg", %,Background -> None]
$\endgroup$
4
  • $\begingroup$ Why not use BoundaryDiscretizeRegion[ ImplicitRegion[x^2 + y^3 < 2, {{x, -2, 2}, {y, -2, 2}}], Frame -> True] ? $\endgroup$
    – cvgmt
    Jan 7, 2022 at 13:49
  • $\begingroup$ @cvgmt But the background is white still $\endgroup$
    – yode
    Jan 7, 2022 at 14:51
  • $\begingroup$ Open your svg file in gimp and it shows a hatched background suggesting that it is transparent ? $\endgroup$
    – Syed
    Jan 7, 2022 at 15:01
  • $\begingroup$ @Syed No, it is WHITE but not transparent, the transparent background is my after... $\endgroup$
    – yode
    Jan 7, 2022 at 15:33

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.