1
$\begingroup$

I'm using Mathematica 10 to render some figures, and I'm noticing some strange behaviour with EPS figures. I'm making figures like the one below in EPS format.

enter image description here

And to do so, I use some code like this;

(*Set up an option to reduce size of EPS files!!! *)
Map[SetOptions[#, 
Prolog -> {{EdgeForm[], Texture[{{{0, 0, 0, 0}}}], 
   Polygon[#, VertexTextureCoordinates -> #] &[{{0, 0}, {1, 
      0}, {1, 1}}]}}] &, {Graphics3D, ContourPlot3D, 
   ListContourPlot3D, ListPlot3D, Plot3D, ListSurfacePlot3D, 
   ListContourPlot, ListVectorPlot3D, ParametricPlot3D, RegionPlot3D, 
   RevolutionPlot3D, SphericalPlot3D, VectorPlot3D, BarChart3D}];

M = Import["beta9.csv"];

(*Scans through the csv file, for every 1 draws Red sphere at a \
height of z = 42, for every 0.5 it draws a green sphere...*)
draw[0, _] = {};
draw[v : Except[0], {y_, x_}] := {v /. {0.5 -> Green, 1 -> Red}, 
 Sphere[{x, y, 42}]};
J = Graphics3D[{Opacity[0.5], MapIndexed[draw, M, {2}]}];

(*pulls in another map to display under the spheres*)
O2map = Import["O2Nan.csv"];


setupimage = 
 ListPlot3D[O2map, MaxPlotPoints -> 300, Mesh -> None, 
 DataRange -> {{0, 200}, {0, 200}}, PlotRange -> {0, 40}, 
 ColorFunction -> ColorData["TemperatureMap"], 
   BaseStyle -> {FontSize -> 14}, BoxRatios -> {1, 1, 1}];


t1 = Show[J, setupimage, BoxRatios -> {1, 0.5, 0.3}, 
 PlotLabel -> "(a) Quick test data
 ", AxesLabel -> {None, None, "(Test Axis)"}, Axes -> True, 
 Ticks -> {{{0, 0}, {25, 125}, {50, 150}, {75, 375}, {100, 
  500}, {125, 625}, {150, 750}, {175, 875}, {200, 1000}}, {{0, 
  0}, {25, 125}, {50, 250}, {75, 375}, {100, 500}, {125, 
  625}, {150, 750}, {175, 875}, {200, 1000}}, {0, 10, 20, 30, 
 40}}, AxesStyle -> {Black, Black, Purple} , 
  BaseStyle -> {FontSize -> 18}, ImageSize -> {800, 800}, 
 ViewAngle -> All ]

This works fine, and renders quickly. To get an EPS, I simply enter

 Export["testdata1.eps",t1]

and it works fine, quickly producing an image file. However, if I load a different CSV (for example, beta6.csv) , the rendering in Mathematica is still quite quick and displays an image like this-

enter image description here

However, if I try using Export to eps, it takes literally hours and uses practically all of my systems 8gb of ram. Worse, if I try to export an image with lots of spheres like this

enter image description here

It renders in Mathematica but will not work with Export, forcing Windows to stop the process after many hours due to low memory. It would appear the process of exporting to an EPS causes problems, and the obvious solution might be to just use a different format but Im curious if there's a way around this. Also, does right clicking save as work differently than export? I'd try it but Im wary of freezing my machine yet again!

If anyone is curious, Sample data here - Underlying constant curve data , Rapid Export csv (shown in (a)), Loads of spheres, will freeze, as shown in (c)

$\endgroup$
  • $\begingroup$ Have you tried just to export the image to EPS instead of all the vector information? Export["testdata1.eps",t1,"Image"] $\endgroup$ – Edmund Apr 17 '15 at 9:52
  • $\begingroup$ I haven't actually - let me try that now! $\endgroup$ – DRG Apr 17 '15 at 9:54
  • $\begingroup$ Hmmm.. tried it there but it told be "Image" wasn't a valid option in EPS format, which kind of makes sense I suppose, if EPS is vector based? $\endgroup$ – DRG Apr 17 '15 at 9:58
  • $\begingroup$ Try Export["testdata1.eps",t1, "AllowRasterization"->True] $\endgroup$ – Edmund Apr 17 '15 at 10:03
  • $\begingroup$ Thanks so much -that worked a treat. If you want to post it as an answer I'm happy to accept! $\endgroup$ – DRG Apr 17 '15 at 10:48
2
$\begingroup$

You can export just the image to EPS by allowing rasterisation with the "AllowRasterization" option in Export.

Export["testdata1.eps",t1,"AllowRasterization"->True]

Hope this helps.

$\endgroup$
  • $\begingroup$ Thank you very much - this drastically speeds up process without throttling my computer! $\endgroup$ – DRG Apr 17 '15 at 11:06

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.