1

I have the following simple Mathematica code:

Clear["Global`*"];
x = Cos[t];
y = Sin[t];
L1 = ParametricPlot3D[{x, y, t}, {t, 0, 50}, 
   PlotStyle -> {Blue, Thickness[0.003]}, Axes -> True, 
   AxesLabel -> {"x", "y", "t"}, BoxRatios -> {1, 1, 1}, 
   AxesStyle -> Directive[Black, FontSize -> 17, FontFamily -> "Helvetica"], 
   PlotPoints -> 500, PlotRange -> All, ImageSize -> 500];
L2 = Graphics3D[{EdgeForm[None], Opacity[0.2], GrayLevel[0.1], 
Specularity[White, 20], Mesh -> None, Lighting -> None, 
Cuboid[{-1, -1, 38}, {1, 1, 50}]}];
P1 = Show[{L1, L2}, ViewPoint -> {1.3, -2.4, 1.5}] 

However, when I try to export this three-dimensional plot in eps format, all the part of function which is inside the cuboid, that is when z>38 does not appear. It seems that somehow during the export the options Opacity is overruled. Is there a way to export this plot correctly?

VividD
  • 3,660
  • 4
  • 26
  • 42
Vaggelis_Z
  • 8,740
  • 6
  • 34
  • 79
  • To fill all the space above the plane z=38 replace your L2 with L2 = Graphics3D[{Opacity[0.2], GrayLevel[0.1], Lighting -> None, Cuboid[{-1, -1, 38}, {1, 1, 50}]}]. – VLC Jan 09 '13 at 13:45
  • @VLC Great! Using the Cuboid the issue regarding the dark output is solved. However, when I export the .eps file the part of the function inside the Cuboid (that is when z>38) is not shown as if there was no Opacity. Any ideas about that? – Vaggelis_Z Jan 09 '13 at 14:26
  • I think that the issue is related to the fact that EPS does not support true transparency (see here – VLC Jan 09 '13 at 16:06
  • @VLC Very illuminating piece of information. Does this mean that there is no way to export this plot correctly? Should I edit and rename my post here? – Vaggelis_Z Jan 09 '13 at 16:11
  • However, if you export to PDF, the transparency will be preserved. In many places where one wants EPS, e.g., for use in LaTeX, you can often use PDF just as well. – murray Jan 09 '13 at 16:30
  • Or you can chose to rasterize the image: Rasterize[P1, RasterSize -> 600, ImageSize -> 400]. – VLC Jan 09 '13 at 16:31
  • @VLC Thanks a lot! I used the 'Rasterize` option as you suggested and the exported eps output is fine! – Vaggelis_Z Jan 09 '13 at 16:40
  • @murray Yes, I could choose to export to pdf. But then I should use pdfLaTeX option and convert all the images into pdf. – Vaggelis_Z Jan 09 '13 at 16:41
  • @Vaggelis_Z: Right. In fact, contemporary TeX systems tend to use pdfLaTeX as the engine by default. And for many if not most purposes, pdf is an acceptable if not preferred final form for the document. – murray Jan 10 '13 at 14:37

1 Answers1

6

If you want to make sure that all exported EPS will look fine even without explicitly rasterizing the plot every time, you can force the rasterization by this one-time command that you could put at the beginning before creating any of your plots:

Map[SetOptions[#, 
    Prolog -> {{EdgeForm[], Texture[{{{0, 0, 0, 0}}}], 
       Polygon[#, VertexTextureCoordinates -> #] &[{{0, 0}, {1, 
          0}, {1, 1}}]}}] &, {Graphics3D, ContourPlot3D, 
   ListContourPlot3D, ListPlot3D, Plot3D, ListSurfacePlot3D, 
   ListVectorPlot3D, ParametricPlot3D, RegionPlot3D, RevolutionPlot3D,
    SphericalPlot3D, VectorPlot3D, BarChart3D}];

The trick is explained in this answer and the linked ones. You're asking about transparency in particular, so I guess it's not quite a duplicate question, but a duplicate answer...

The plots will be rasterized when exporting to PDF or EPS - the notebook internal plots are not rasterized.

Jens
  • 97,245
  • 7
  • 213
  • 499