1
$\begingroup$

Good Day everybody,

I have difficulties to save both 2D and 3D plots in vectorial format.

I can get acceptable results if I save manually: righ-click on image, "Save Graphic as..." or "Print as...". But I want to automate the process since I have to repeat the process many times. I tried to code and use function Export[], as either .pdf or .svg. However, I cannot manage to have all elements of the plot selectable and modified in Adobe Illustrator, which necessary for what I want to do.

For the 2D example the sizes of elements are not respected: the text get enormous and scrambled, and the 2D MatrixPlot itself the image itself is very low quality and rasterized.

pathFolder = 
  "C:\\Users\\argoNax\\Dropbox\\Exp";

xys = Table[RandomReal[{1, 50}], {rr, 1, 100}, {cc, 1, 100}];

image = MatrixPlot[Reverse[Transpose[xys]],
  ColorFunction -> (ColorData[{"SunsetColors", "Reverse"}][
      Rescale[#, {0, 40}, {0, 1}]] &), ColorFunctionScaling -> False,
  PlotLegends -> Automatic, AspectRatio -> 1, ImageSize -> 400]

Export[pathFolder <> "\\Exp_1.svg", image]

1]

Here is what I see in Illustrator

2]

If I do Export[pathFolder <> "\\NoRast.svg", "AllowRasterization" -> False] (as suggested here), the plot is even worse

For 3D plotting things are also bad and the images can be high definition if I use .pdf, but are alway inevitably rasterized.

surfdata = {{0, 0.0561, 0.0561, 0.0112, 0.0449, 0.0224, 0.0337, 
0.0449, 0.0337, 0.0337, 0.0224, 0.0337, 0.0112, 0.0561, 0.0786, 
0.0561, 0.0786, 0.0449, 0.1235, 0.0898, 0.0674}, {0, 0.0583, 
0.04338, 0.03254, 0.0271, 0.0406, 0.0488, 0.0623, 0.0623, 0.0806, 
0.0603, 0.0657, 0.0583, 0.0630, 0.0549, 0.0691, 0.0508, 0.0203, 
0.0427, 0.0291, 0.0291}, {0, 0.1428, .0808, 0.0864, 0.0987, 
0.1060, 0.1064, 0.1026, 0.0941, 0.0673, 0.0473, 0.0280, 0.0141, 
0.0116, 0.0031, 0.0031, 0.0024, 0.0028, 0.0015, 0.0001, 
0.0000}, {0, 0.1891, 0.19151, 0.2075, 0.1914, 0.1255, 0.0592, 
0.0243, 0.0062, 0.0024, 0.0014, 0.0008, 0.00005, 0.0001, 0.0, 0.0,
 0.0, 0.0, 0.0, 0.0, 0.0}, {0, 0.2602, 0.3983, 0.2693, 0.0637, 
0.00746, 0.0008, 0.0001, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
0.0, 0.0, 0.0, 0.0, 0.0}};

pSurf =
  ListPlot3D[surfdata,
  PlotRange -> {{1, 10}, {1, Length[surfdata]}, {0, 1}}, BoxRatios -> {1.5, 1, 0.75},
  ColorFunction -> (ColorData["Rainbow"][#3] &), ColorFunctionScaling -> {0, 5},
  MeshFunctions -> { #3 &}, Mesh -> 20, MeshStyle -> None,
  Ticks -> {Transpose[{Range[0, 9, 2], Range[0, 450, 100]}], 
  Range[1, Length[surfdata]], Automatic},
  AxesLabel -> {"distance [\[Mu]m]", "time [hours]", "Frequency"}, 
  LabelStyle -> Directive[16, Bold],
  ViewPoint -> {2 \[Pi], -2 \[Pi], 1.5 \[Pi]}, Boxed -> False,
  FaceGrids -> {{-1, 0, 0}, {0, 1, 0}, {0, 0, -1}}
];

Show [ pSurf , ImageSize -> 400]

Export[pathFolder <> "\\Surf.pdf",
  Show [ pSurf , ImageSize -> 400], "CompressionLevel" -> 0, 
  "AllowRasterization" -> False
  ];

4]

I will appreciate any help to save the Export the images by maintaining them in vector form as much as possible. While some 2D plot allow to select all the elements, the 3D plot elements in the notebook image cannot be selected, as far as I have experienced. Therefore, I wonder if saving in vectorial form is even possible!

Bests,

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.