Transfer graphics from Mathematica to Word without loss of quality
If you need to achieve the best possible quality I strongly recommend against using the Clipboard for transferring graphics. Under Windows the clipboard will contain a Windows Metafile generated with display resolution fidelity! This is the reason why you see jaggies.
The same is true for the vector graphics files generated by Mathematica's Save Selection As...
menu item. For achieving the best possible quality always use the Export
command.
Instead of copying I recommend to Export
your graphics as EPS and then import it in your Word document. Note that most scientific journals recommend to provide graphics in the resolution-independent EPS format.
One possible difficulty with EPS is that it does not support semi-transparency. If your graph contains transparent objects you cannot directly Export
it as correct EPS file from Mathematica.
Another problem is that MS Office supports EPS only up to PostScript level 2 while Export
"generally creates PostScript level 2 files, and includes certain level 3 features if appropriate." MS Office fails to import EPS file when it contains PostScript level 3 features and unfortunately it is currently impossible to restrict Export
for writing only level 2 files.
I expand these topics and provide workarounds in these answers:
How can I insert an EPS file exported from RegionPlot into MS Word?
How do I flatten transparency on a graphics, for conversion to eps or similar?
Support for EPS in Office
If you are not satisfied with EPS, I recommend you to Export
your graphics as EMF. EMF has an advantage of being the native vector graphics format on Windows but unlike EPS and PDF it does not support font embedding. EMF files Export
ed from Mathematica also have much lesser vector precision than EPS, PDF and SVG files generated by Export
. So EPS is much more advanced as compared to EMF but also is much more difficult to deal with because MS Office support of this format is rudimentary.
If you use VertexColors
in your graph (which PDF format supports but Mathematica's Export
still does not) or there are other reasons why EPS, EMF and PDF give unsatisfactory results you may consider rasterizing your graph and Export
ing it as PNG with high resolution. This is not always an easy task because Mathematica's Graphics
by default is NOT resolution-independent: Ticks
and TickLabel
s by default do not scale with the whole Graphics
! It is huge headache for any Mathematica user for many years and there is still no easy workaround. In the most cases the best way is to Export
as PDF from Mathematica and then export the graph from your favorite PDF renderer to PNG. Other workarounds include some preprocessing inside of Mathematica and/or using third-party software.
Here is an example of the preprocessing approach which gives small file size without loss of quality:
- How do I plot a histogram with hatched shading?
It is a problem for the reasons @Alexey Popkov explains.
My workaround is to have one graphics format for the publisher and different one for printing PDFs from Word.
For printing PDFs from Word, the one thing that has ended up working nicely for me is to create large PNG files, which you then adjust to size in Word. For sending files to the publisher, you can produce PDF files of the graph at the size you want directly from Mathematica. In other words, you choose the font sizes you want for the text on your graphs and produce them at the size you want. In Inches, the size seems to be 100 units of ImageSize
per inch, so you will use Export["
filePathAndName.pdf",
graphname, ImageResolution->1200, ImageSize->3.75 100]
in order to produce a PDF file that the printer will insert in the text and which graph will have a width of 3.75 inches on the printed page.
You could insert this PDF into Word by using Alt-i-o (/insert/object, then the tab "From File") but my experience is that its quality will deteriorate. It will neither look good on the page nor in the PDF printed from Word.
Instead, you need to produce a PNG file in large resolution; in this example use Export["
filePathAndName.png",
graphname, ImageResolution->1200, ImageSize->3.75 100]
. Import the graph into your Word document using Alt-i-p-f (/insert/picture/from file). Word will ignore the size that you have set but you can right-click the graph, choose "Size and Position" from the drop-down menu, and set the size you want (3.75 inches width in the example). This will look sharp on the Word screen and the PDF files you produce from Word.
Now, because I work in Mathematica in 75% magnification, these graphs look far too small on my screen. So for the screen, I use larger font and resolution of image units for inches. I use 267 for inch units of graph size and 42 as the font size that corresponds to fonts of size 12. At my initialization cell, I have a line like If[True,{ftsz=12,imgsz=100},{ftsz=42,imgsz=267}];
and define font sizes and image sizes using the variables, e.g., Graph[
primitives and any fonts defined using ftsz
,BaseStyle->{
font family choices etc. ,FontSize->ftsz},ImageSize->3.75 imgsz]
. The graphs will be nice and large to see on the screen while you are building them using Mathematica and the False
setting in the If
statement, then render them again for Export
ing after changing that If
statement to True
. But be careful, if you export the large-dimension PNG graph not to set resolution at 1200 or you may, like me, get out of memory errors. But it may look better in Word than the 3.75-inch graph with the 1200 resolution.
I know, this should be easier. Perhaps I am missing some trick and someone will point it out in the comments.