0
$\begingroup$

I have a question about Mathematica images exporting. I have created 3d (SpericalPlot) with coloring function on it and then exported it to pdf. Is there any possibility to make more vector graphics look - boundary pixels between white background and other elements ?

Part of the code:

axes[x_, y_, z_, a_] := 
Graphics3D[
Join[{Red, Arrowheads[a], 
Arrow[Tube[#, 0.015]]} & /@ {{{-x, 0, 0}, {x, 0, 0}}, {{0, -y, 0}, {0, y, 0}}, {{0, 0,-z}, {0, 0, z}}}, 
{Text[Style["\!\(\*SubscriptBox[\(S\), \(x\)]\)", 18, Bold, Black], {1.1*x, 0.1*y, 0.1*z}], 
Text[Style["\!\(\*SubscriptBox[\(S\), \(y\)]\)", 18, Bold, Black], {0.1 *x, 1.1*y,0.1*z}], 
Text[Style["\!\(\*SubscriptBox[\(S\), \(z\)]\)", 18, Bold, Black], {0.1*x, 0.1*y, 1.1*z}]}]];

Ploting:

Show[SphericalPlot3D[1, {\[Theta], 0, \[Pi]}, {\[Phi], 0, 2 \[Pi]}, 
ColorFunction -> Function[{x, y, z, \[Theta], \[Phi], r}, 
ColorData["DarkRainbow"][QMap[\[Theta], \[Phi], data]/MaxQ]], 
ColorFunctionScaling -> False, Mesh -> False, Axes -> False, 
PlotPoints -> 200, ImageSize -> {350, 350}, Boxed -> False, 
ViewPoint -> {-3, 0, 0}, ViewAngle -> 0.37], 
axes[1.2, 1.2, 1.2, 0.03], 
PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}];

Saving:

Export["im.pdf", Style[Show[p3, Prolog -> {Opacity[0], Texture[{{{0, 0, 0, 0}}}], 
VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}}, 
Polygon[{{0, 0}, {.1, 0}, {.1, .1}}]}], Antialiasing -> True]

Mathematica 3d image

$\endgroup$
  • $\begingroup$ Under Preferences -> Appearance -> Graphics, is antialiasing set to "highest quality"? $\endgroup$ – C. E. Jan 10 '15 at 19:23
  • $\begingroup$ You could try the function rasterTrick from my answer here. If that doesn't work, please explain the issue in more detail with some sample code. $\endgroup$ – Jens Jan 10 '15 at 22:23
  • $\begingroup$ I have already used Your trick to get rid of meshing lines :) $\endgroup$ – WoofDoggy Jan 10 '15 at 22:46
  • $\begingroup$ I've inserted part of the code in my question - antialiasing does not work $\endgroup$ – WoofDoggy Jan 10 '15 at 23:09
  • $\begingroup$ I used ImageResolution set to 1500 and it is better, but if I want higher e.g. 1800 my Mathematica 10 crashes on Windows 7 :( $\endgroup$ – WoofDoggy Jan 10 '15 at 23:37
3
$\begingroup$

As I said in the comment, it's possible to get better results with the trick I used in this answer. I'm doing this in the Export command below. For the explanation, follow the link.

Here is a version of your code that produces an image:

axes[x_, y_, z_, a_] := 
  Graphics3D[
   Join[{Red, Arrowheads[a], 
       Arrow[Tube[#, 0.015]]} & /@ {{{-x, 0, 0}, {x, 0, 0}}, {{0, -y, 
        0}, {0, y, 0}}, {{0, 0, -z}, {0, 0, z}}}, {Text[
      Style["\!\(\*SubscriptBox[\(S\), \(x\)]\)", 18, Bold, 
       Black], {1.1*x, 0.1*y, 0.1*z}], 
     Text[Style["\!\(\*SubscriptBox[\(S\), \(y\)]\)", 18, Bold, 
       Black], {0.1*x, 1.1*y, 0.1*z}], 
     Text[Style["\!\(\*SubscriptBox[\(S\), \(z\)]\)", 18, Bold, 
       Black], {0.1*x, 0.1*y, 1.1*z}]}]];

p3 = Show[
   SphericalPlot3D[1, {θ, 0, Pi}, {ϕ, 0, 2 Pi}, 
    ColorFunction -> 
     Function[{x, y, z, θ, ϕ, r}, 
      ColorData["DarkRainbow"][.1]], ColorFunctionScaling -> False, 
    Mesh -> False, Axes -> False, PlotPoints -> 200, 
    ImageSize -> {350, 350}, Boxed -> False, ViewPoint -> {-3, 0, 0}, 
    ViewAngle -> 0.37], axes[1.2, 1.2, 1.2, 0.03], 
   PlotRange -> {{-1.2, 1.2}, {-1.2, 1.2}, {-1.2, 1.2}}];

Export["im.pdf", 
 Style[Show[p3, 
   Prolog -> {Opacity[0], Texture[{{{0, 0, 0, 0}}}], 
     VertexTextureCoordinates -> {{0, 0}, {1, 0}, {1, 1}}, 
     Polygon[{{0, 0}, {.1, 0}, {.1, .1}}]}], Magnification -> 2]]

In the Style command, I only specify Magnification -> 2. Now the PDF file looks like this on my screen:

screenshot

To compare with your screen shot, I zoomed in:

zoomed

You can increase the Magnification to get smooth appearance for larger zoom as well. The on-screen appearance will also depend on the PDF viewer. I used Preview on Mac OS X. For this to work, it's important to keep the Prolog in Show (which is what I call rasterTrick in this answer) because otherwise the export won't be rasterized and the file will be huge.

As to the question whether the 3D graphics output p3 can be converted to a smaller but 2D vector format, the answer is no: there is no built-in functionality for that.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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