Skip to main content

graphics - How can I insert an EPS file exported from RegionPlot into MS Word?


I generate a figure using RegionPlot and then Export it as "EPS". When I insert this picture into MS Word, it doesn't work.


The figure is generated by the following code:


Constraint1[α1_, α2_] := Cos[α2] (Sin[α2]/Sin[α1] - Sin[α2] Cot[α1] + Cos[α2]);

CSSSS = Show[

RegionPlot[
0 < α1 < α2 < 60 && Constraint1[α1*π/180, α2*π/180] > 1/2,
{α1, 0, 59.999}, {α2, 0, 60},
BaseStyle -> {FontFamily -> Times, 25}, ImageSize -> 600,
FrameLabel -> {Style["\!\(\*SubscriptBox[\(α\), \(1\)]\)(\[Degree])", 28],
Style["\!\(\*SubscriptBox[\(α\), \(2\)]\)(\[Degree])", 28]},
PlotLabel -> Style["Value Range of Basic Angles", 25, Black],
FrameStyle -> Directive[Thickness[0.003], Black],
Epilog -> {Inset[Style["(45, 60)", 25], {40, 59}],
Inset[Style["(45, 50)", 25], {50, 49}],

Inset[Style["(40, 50)", 25], {35, 49}]}],
ListPlot[{{45, 60}, {45, 50}, {40, 50}}, PlotStyle -> Red]]

Export["xxx.eps", CSSSS]

Screenshot after importing the "xxx.eps" file into MS Word:



screenshot




Answer




The figure you are trying to Export into EPS format contains semi-transparent objects unsupported by this format:


Cases[CSSSS, _Opacity, Infinity]


{Opacity[0.3]}

Actually all the filling produced by RegionPlot is semi-transparent as you can easily find using my shortInputForm function:


CSSSS // shortInputForm

Since transparency actually isn't necessary for your image you can simply replace default semi-transparent filling with non-transparent color (which exactly reproduces the default styling) by adding the following option to RegionPlot:



PlotStyle -> RGBColor[0.8105251`, 0.8520337`, 0.9129394`]

Now


Cases[CSSSS, _Opacity, Infinity]


{Opacity[1]}

while the plot looks exactly as it was looking originally.


In the general case when you have semi-transparent objects overlapping with some non-uniform background you have to perform transparency flattening, see this answer for details.



However even after removing transparency MS Word still cannot import the EPS file Exported from Mathematica 10.2 (which I currently work with, but the same is true for version 8.0.4). The most probable reason is that this EPS file contains PostScript Level 3 instructions which MS Office EPS Import Filter cannot understand. In this answer I discuss limitations of the latter and known methods allowing to generate EPS files compatible with MS Office. The most reliable way is to Export as PDF from Mathematica, then use free utility pdftops or pdftocairo from Poppler utilities for Windows for generating Level 2 EPS file as follows:


pdftops -level2 -eps input.pdf
pdftocairo -level2 -eps input.pdf

Following the pdftocairo route I obtain EPS file which MS Word 2003 successfully imports producing the following visual appearance in Word:


screenshot


As you can see, the Greek letters α are not displayed and instead of Times it displays all text as Arial. But what you see is not the actual imported figure: it is just a preview automatically generated by MS Office EPS Import filter which is known to be inaccurate. For the purposes of printing to PostScript printers this preview isn't used by Word: it sends original PostScript code to the PostScript printers (this code is embedded into Word document when you import a EPS file but cannot be displayed because Word cannot render PostScript). The preview is used only for display purposes and for printing to non-PostScript printers. Let us try to print this Word document to the "Adobe PDF" virtual printer and check how generated PDF file looks in Adobe Acrobat:


screenshot


The figure looks perfectly and the glyph α is correctly embedded!





If you are not satisfied with the above result you have to go through the Adobe Illustrator route described in the linked answer: import the PDF file Exported from Mathematica into Illustrator, edit it in order to fix incorrectly imported text, then export as EPS with unchecked option "Include CMYK PostScript in RGB Files". From my experience, EPS files exported from Illustrator this way are always previewed correctly in MS Word.


Comments

Popular posts from this blog

plotting - How to draw lines between specified dots on ListPlot?

I would like to create a plot where I have unconnected dots and some connected. So far, I have figured out how to draw the dots. My code is the following: ListPlot[{{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4,13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full] I have thought using ListLinePlot command, but I don't know how to specify to the command to draw only selected lines between the dots. Do have any suggestions/hints on how to do that? Thank you. Answer One possibility would be to use Epilog with Line : ListPlot[ {{1, 1}, {2, 2}, {3, 3}, {4, 4}, {1, 4}, {2, 5}, {3, 6}, {4, 7}, {1, 7}, {2, 8}, {3, 9}, {4, 10}, {1, 10}, {2, 11}, {3, 12}, {4, 13}, {2.5, 7}}, Ticks -> {{1, 2, 3, 4}, None}, AxesStyle -> Thin, TicksStyle -> Directive[Black, Bold, 12], Mesh -> Full, Epilog -> { Line[ ...

equation solving - Invert and fit implicitly defined curve

I need to fit an implicitly defined curve. I thought I could get some data out of Solve , and then using FindFit . Therefore, I would like to find the relation the parametric curve defined by $F(x,y)=0$: Solve[-(1/2) + 1/2 (0.41202 BesselK[0, 0.1 Sqrt[x^2 + y^2]] + (0.101483 x BesselK[1, 0.1 Sqrt[x^2 + y^2]])/Sqrt[x^2 + y^2]) == 0, y] But I can't get an output: Solve was unable to solve the system with inexact coefficients or the system obtained by direct rationalization of inexact numbers present in the system. Since many of the methods used by Solve require exact input, providing Solve with an exact version of the system may help. >> Edit: In particular, I would like to fit the data coming from the curve with the expression of another curve, and not with a function $f(x)$. In particular, since this clearly looks like a cardioid , I would like it to fit to something like it. What other strategies could I try?

dynamic - How can I make a clickable ArrayPlot that returns input?

I would like to create a dynamic ArrayPlot so that the rectangles, when clicked, provide the input. Can I use ArrayPlot for this? Or is there something else I should have to use? Answer ArrayPlot is much more than just a simple array like Grid : it represents a ranged 2D dataset, and its visualization can be finetuned by options like DataReversed and DataRange . These features make it quite complicated to reproduce the same layout and order with Grid . Here I offer AnnotatedArrayPlot which comes in handy when your dataset is more than just a flat 2D array. The dynamic interface allows highlighting individual cells and possibly interacting with them. AnnotatedArrayPlot works the same way as ArrayPlot and accepts the same options plus Enabled , HighlightCoordinates , HighlightStyle and HighlightElementFunction . data = {{Missing["HasSomeMoreData"], GrayLevel[ 1], {RGBColor[0, 1, 1], RGBColor[0, 0, 1], GrayLevel[1]}, RGBColor[0, 1, 0]}, {GrayLevel[0], GrayLevel...