Export Plots to PNG in Printout Style

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];


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 • 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 '14 at 15:39
• 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 '14 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 '14 at 16:59
• 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 '14 at 17:45
• It might be nice to point out that the original setting is ScreenStyleEnvironment -> "Inherited". – Michael E2 Aug 19 '14 at 19:23

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];  Shown here using Rasterize: 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).

• 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 '14 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 '14 at 16:42