Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

When creating a plot in Mathematica 10 (OS X 10.9.4 and Win 7) the FrameLabel and Ticks are greyish and only the Frame itself is black (see Screenshot bellow). Only when exporting the plot to PDF all elements are black. However when I try to export the plot to PNG, then the resulting PNG looks exactly like the screenshot.

Is there a way to use the Printout style (as is used when exporting to PDF), when exporting plots to raster graphics (bitmap) formats such as PNG?

Plotting:

 plot = Plot[x^2, {x, 0, 3}, Frame -> True, 
 FrameStyle -> Directive[Thick, FontSize -> 24], 
 FrameLabel -> {"x", "y"}]

and Exporting:

 Export["plot.png", plot];
 Export["plot.pdf", plot];

Comparison

share|improve this question

2 Answers 2

up vote 12 down vote accepted

I had the same problem after switching to Mathematica 10. The issue here is the following:

Export uses Rasterize to create the png image. The StyleEnvironement, which is used in Rasterized, cannot be specified as an option but is given by the $FrontEnd object (not by the EvaluatingNotebook[]!). You can change the StyleEnvironement by

SetOptions[$FrontEnd, ScreenStyleEnvironment -> "Printout"]

When you use Export or Rasterize now, you will obtain the "Printout" style.

Note: This has been tested on Mathematica 10, Win7, 64bit. Other versions (Mac) might behave differently (see comments below). Consider using the $FrontEndSession object, as suggested by Michael E2 below.

Related questions on Stackexchange:

How to Rasterize in "Printout" style

http://stackoverflow.com/questions/6093559/how-to-export-graphics-in-working-style-environment-rather-than-printout )

share|improve this answer
3  
I believe changing $FrontEnd changes the setting in init.m, and the change will persist until it is changed back. I think you ought to warn users of that. –  Michael E2 Aug 19 at 15:39
1  
I verified that this is true: (FrontEnd/init.m) is modified, i.e. the proposed change is persistent! This might be desired in some cases. –  denizb Aug 19 at 16:43
    
Yes, it might be desired. I was thinking of an unsuspecting visitor to the site being caught off-guard by it. –  Michael E2 Aug 19 at 16:59
    
This doesn't quite work for me. Setting the $FrontEnd, I have to restart the front end before it will take effect. –  Michael E2 Aug 19 at 17:20
1  
There might be differences with the different versions: On my instance (MA10, Win7, 64bit) it works directly and reversibly. On my colleagues Version (MA10, Mac OS X) there seems to be issues. –  denizb Aug 19 at 17:45

I could not get it to work with $FrontEnd, but setting the ScreenStyleEnvironment on $FrontEndSession worked for me. Here text cells get two different backgrounds and font sizes, depending on the environment. ("Printout" is pink and large.)

sseOpt = Options[$FrontEndSession, ScreenStyleEnvironment];
    SetOptions[$FrontEndSession, ScreenStyleEnvironment -> "Printout"];
Export["file.png", Cell["Printout text", "Text"]]
SetOptions[$FrontEndSession, sseOpt];

enter image description here

Shown here using Rasterize:

enter image description here

Notes:

The switching of environments causes some dancing around in the windows. The magnification is left in the "Printout" setting until you edit the notebook, when it will change to the former setting. This seems like a bug, but it's in both V9/V10.

Changes to $FrontEnd are written in the start-up file init.m. Such changes will be permanent (until changed again, that is).

The default setting is ScreenStyleEnvironment -> "Inherited" (for both $FrontEndSession and $FrontEnd).

share|improve this answer
    
I was going to address the related (if not duplicate) question 10065, but I couldn't reproduce the author's problem in V10, V9, nor V8.0.4. So I'll leave my answer here for now. –  Michael E2 Aug 19 at 16:38
    
I considered, if this is a duplicate and decided that it is not, because the original question relates to Export (and only indirectly to Rasterize) –  denizb Aug 19 at 16:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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