4
$\begingroup$

I export an image in SVG format using the Export command (code below). I find the quality okayish, but not great. I tried playing around with PlotPoints and MaxRecursion, but without being able to improve things significantly. Are there other parameters for ParametricPlot and/or Export that can improve the output quality?

xmin = -1;
xmax = 1;
ymin = -1.5;
ymax = 1.5;
darkblue = RGBColor["#004699"];
lightblue = RGBColor["#0071b9"];
thick = 0.001;

f[x_, y_] := {Exp[x]*Cos[y], Exp[x]*Sin[y]};

F[x_, y_, t_] := (1 - t)*{x, y} + t*f[x, y];

t = 0.75;

homotopy = Table[ParametricPlot[{F[i, j + s*ymax, t], F[i + s*xmax, j, t]}, {s, -5, 5}, PlotStyle -> {{If[i == 0, darkblue, If[i == Floor[i], lightblue, Black]], If[i == 0, Thickness[5*thick], If[i == Floor[i], Thickness[3*thick],Thickness[thick/10]]]}, {If[j == 0, darkblue,If[j == Floor[j], lightblue, Black]], If[j == 0,Thickness[5*thick],If[j == Floor[j], Thickness[3*thick], Thickness[thick/10]]]}},PlotRange -> {{xmin, xmax}, {ymin, ymax}}, PlotPoints -> 100,MaxRecursion -> 15, Background -> None, PlotRangeClipping -> True,Axes -> False], {i, 2*xmin, 2*xmax, 1}, {j, 5*ymin, 5*ymax, 1}];

Export["~/Desktop/homotopy.svg",Show[homotopy]];

Edit: Here is how things look like upon zooming a bit into the picture (using ImageResolution->600 as proposed below)

enter image description here

Edit II: A similar issue is described here

$\endgroup$
7
  • $\begingroup$ Export it as a pdf or eps? $\endgroup$
    – chris
    Commented Sep 15, 2021 at 10:17
  • $\begingroup$ otherwise you can always do Export["~/Desktop/homotopy.svg", Show[homotopy], ImageResolution -> 600]; $\endgroup$
    – chris
    Commented Sep 15, 2021 at 10:43
  • $\begingroup$ @chris Thanks, but this doesn't really help, see the edit, neither does exporting to pdf or eps $\endgroup$
    – 220284
    Commented Sep 15, 2021 at 11:09
  • 2
    $\begingroup$ Change stroke-linecap:square to stroke-linecap:round and stroke-miterlimit:3.25 to something like stroke-miterlimit:0.25 in the SVG file. I didn't have time to see if we could make Mma's SVG converter do that for you. $\endgroup$
    – Michael E2
    Commented Sep 15, 2021 at 12:31
  • 1
    $\begingroup$ @MichaelE2 That's excellent! Many thanks indeed! Perhaps you can phrase it as an answer, so that I can accept and upvote? $\endgroup$
    – 220284
    Commented Sep 15, 2021 at 12:40

1 Answer 1

4
$\begingroup$

This makes it look smooth:

Change stroke-linecap:square to stroke-linecap:round and stroke-miterlimit:3.25 to something like stroke-miterlimit:0.25 in the SVG file. I didn't have time to see if we could make Mma's SVG converter do that for you.

After some spelunking, I could not find a way to tweak the SVG parameters from within Mathematica.

Here's a way to make the adjustment within Mathematica:

Export[
 FileNameJoin[{$TemporaryDirectory, "homotopy.svg"}],
 StringReplace[
  ExportString[Show[homotopy], "SVG"],
  {"stroke-linecap:square" -> "stroke-linecap:round",
   "stroke-miterlimit:3.25" -> "stroke-miterlimit:0.25"}
  ],
 "Text"]
$\endgroup$
1
  • $\begingroup$ Great answer! Many thanks! $\endgroup$
    – 220284
    Commented Sep 17, 2021 at 10:40

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.