5

I am having problems displaying histograms exported as .eps in Word 2010. I don't have problems though displaying them in a specialized .eps viewer. (Postsript viewer from Rampant logic) I am writing histograms because there were no problems in exporting or displaying any other plot type.

plot = Histogram[RandomVariate[NormalDistribution[0, 1], 200]]
Export["plot.eps", plot]

Mathematica graphics

Could it be that .eps files for histograms are corrupted? I did not find a way to attach the .eps file, so I hope that I am not the only person with this problem, although this is kind of wicked.

Szabolcs
  • 234,956
  • 30
  • 623
  • 1,263
malumno
  • 349
  • 1
  • 11
  • 2
    Try printing your Word document on a PostScript printer (or a virtual printer that outputs PDF) and see if it displays fine that way. Word does not support displaying EPS on screen. It does give a rough approximation sometimes, but this is just an approximation, not the final appearance. – Szabolcs Feb 26 '13 at 17:57
  • 2
    This seems to be more of a Word problem than anything to do with Mathematica. The usual format to use if you want to include figures in a Word document is EMF, not EPS. – Oleksandr R. Feb 26 '13 at 17:57
  • Reference for my previous comment: http://office.microsoft.com/en-us/word-help/graphics-file-types-word-can-use-HP005189346.aspx EDIT This is for Word 2003, not sure if 2010 is different in this repsect – Szabolcs Feb 26 '13 at 17:58
  • 1
    Thanks for your swift comments. I tried both printing to pdf and printing to paper and in both cases it only shows "This image cannot currently be displayed", the same message as in word,perhaps some standard error image. I want to use EPS because the quality of the plots is much better. EMF shows compression artifacts. Also I posted the question here as I thought it might be a bug in Mathematica which messes up only the histogram EPS code, but not the EPS code of any other plot. – malumno Feb 26 '13 at 18:07
  • 1
    Hm, you are right. There also seems to be an issue, particular to the histogram, with EMF output: EMF is a vector format, just like EPS, yet this plot is being rasterized for export (hence the artifacts you see--they are not characteristic of the EMF format in general). I wonder what it is about histograms that causes difficulties with vector output formats. – Oleksandr R. Feb 26 '13 at 18:48
  • Can't even export as an EMF from MMA on a Mac. However, at least on Word on OS X I can place an exported EPS or PDF of the histogram and it looks good, no evidence of being rasterized. MMA 9. – s0rce Feb 26 '13 at 23:29
  • @s0rce oh, apparently it is just EMF that suffers this rasterization problem in the case of the histogram. EPS output seems okay here; it can be inserted into Word 2003 and 2010 without any problem. I must admit I didn't know Word could comprehend PostScript, although I never had any trouble with EMF before now either. – Oleksandr R. Feb 27 '13 at 18:07
  • Oh so Mathematica exported EPS histograms work fine on your machines? My system is Mathematica 9, Word 2010 and Windows 7. By the way Word 2010 only displays the preview image integrated into PostScript code. EPS output in Word on the monitor always looks crappy, but perfect in print. – malumno Feb 28 '13 at 09:22
  • @OleksandrR. - could you please let me know what you did to get EPS to display in Word 2010? I assume this is on Windows, not the Mac? I can't get it to display at all, for bar-chart/histograms or line plots or any other kind of graphic. – Verbeia May 21 '14 at 02:32

2 Answers2

1

This is not a complete solution to your problem, since I face the same issue (see also here). You can improve the screen display of EPS in Word by using the ImageResolution option, like this:

Export["epstestg.eps", epstest, {"Graphics"}, ImageResolution -> 300]

A word of warning that this feature expects actual Graphics. If you are actually wanting to export a Grid of graphics and other things as a single graphic (which my application requires), you will need to do something like this to get the thing to be exported:

epstest = 
 With[{mygraph = 
    mySpecialBarChartFunction[fakedata, ChartLayout -> "Stacked"]},
  With[{dims = ImageDimensions[Rasterize[mygraph]]}, 
   Graphics[Inset[mygraph], ImageSize -> First[dims ], 
    AspectRatio -> (dims[[2]]/dims[[1]]), 
    BaseStyle -> {FontFamily -> "Arial", FontSize -> 16}] ]]

There is always a "But..."

In my tests, this results in acceptable results on-screen. It also prints nicely.

But...

When you then try to save the resulting Word document as a PDF, the EPS graphics show as black rectangles.

If I work out a workaround to this, I will revise this answer.

Verbeia
  • 34,233
  • 9
  • 109
  • 224
0

I have found a very good method. Right click on the image in mathematica as usual and save the image as .eps.

Open this .eps file in Adobe Illustrator.

  1. Press Ctrl + A to select all the elements of the image.
  2. Press Ctrl + C to copy all the selected elements.

Open word paste the image by pressing Ctrl + V. Save as pdf in the usual way. You will get a non-spoiled image.

m_goldberg
  • 107,779
  • 16
  • 103
  • 257
fermibot
  • 29
  • 2