I would like to export the following figure in a ".wmf" type, so as to edit it further in PPT. But the exported figure size is too big, about 2 MB. The reason is that there are too many data points in the main figure. So I hope to export the frame as a vector, while keep the main figure a scalar (e.g., .jpg type). In this case, I guess the whole size will be smaller. Anyone can help me by realizing this purpose? Thank you all very much.

The code is like this

fig1 = ListLinePlot[Table[{x, 200000 Exp[-x*x/10] Abs[Sin[100 x ]]}, {x, -10, 10, 0.01}], PlotStyle -> {Green, Opacity[.8]}, PlotRange -> All, Frame -> True, Axes -> False,  LabelStyle -> Directive[Black, FontSize -> 18], AspectRatio -> .8, FrameTicks -> { {{{0, "0"}, {50000, "50k"}, {100000,    "100k"}, {150000, "150k"}, {200000, "200k"}}, {{0,  ""}, {50000, ""}, {100000, ""}, {150000, ""}, {200000,   ""}}}, {{{-10, "-10"}, {-5, "-5"}, {0, "0"}, {5, "5"}, {10,         "10"}}, {{-10, ""}, {-5, ""}, {0, ""}, {5, ""}, {10, ""}}}}, FrameLabel -> {{"Intensity", None}, {"Delay (mm)", None}},  ImageSize -> {300, 300}];
fig2 = ListLinePlot[   Table[{x, 200000 Exp[-x*x/10]}, {x, -10, 10, 0.01}],    PlotStyle -> {Blue, Thick}];
fig3 = Show[fig1, fig2]
Export["fig.wmf" , fig3] 

The figure is like this enter image description here

  • 3
    $\begingroup$ Isn't a bitmap more like a matrix than a scalar? $\endgroup$ – Oleksandr R. Sep 11 '15 at 14:48
  • 1
    $\begingroup$ aside to the question, never use jpg for line-art type graphics. Look at all the dirty speckles around every sharp line.. $\endgroup$ – george2079 Sep 11 '15 at 15:09

To directly answer the question (Not to say its a good idea) you can do something like this:

raster = Rasterize[Show[fig3, Frame -> False], ImageSize -> {300, 300}];
Graphics[{Inset[raster, {0, 0}, {150, 30}, 20]}, 
   PlotRange -> {{-10, 10}, {0, 200000}}, Frame -> True, Axes -> False, 
   LabelStyle -> Directive[Black, FontSize -> 18], AspectRatio -> .8, 
     FrameTicks -> {{{{0, "0"}, {50000, "50k"}, {100000, "100k"}, {150000,
      "150k"}, {200000, "200k"}}, {{0, ""}, {50000, ""}, {100000,""},
        {150000, ""}, {200000, ""}}}, {{{-10, "-10"}, {-5, "-5"},
        {0, "0"}, {5, "5"}, {10, "10"}}, {{-10, ""}, {-5, ""},
         {0, ""}, {5, ""}, {10, ""}}}}, 
    FrameLabel -> {{"Intensity", None}, {"Delay (mm)", None}}, 
       ImageSize -> {300, 300}]

Note I manually putzed with the inset scaling to get the raster to align by eye. I also manually set the plot range after looking at PlotRange /. AbsoluteOptions[fig3] The procedure could probably be automated if you work at it.

enter image description here

| improve this answer | |
  • $\begingroup$ This answer is just what I need. Thank you so much! $\endgroup$ – user14634 Sep 14 '15 at 1:55
  • $\begingroup$ After I insert this figure to PPT, then add some note(using "ungroup" in PPT), and finally save it as PDF. The size is 22.6kB, and the frame is in vector!! $\endgroup$ – user14634 Sep 14 '15 at 2:17

You have expressed two really BAD ideas: Export to outdated WMF format and edit the vector figure in PowerPoint which is not intended for editing vector graphics. With WMF you get low quality and most probably distorted figure, and when you edit it in MS Office you obtain just a junk instead of the original figure.

Do not edit vector figures in MS Office! Add what you need in Mathematica or (if the latter is inconvenient) use specialized software for editing vectors like Inkscape, Illustrator or CorelDraw. For this purpose Export as PDF because it is the most supported vector format in Mathematica AND the most of specialized vector editors can import such files.

If you need to embed vector figure in MS Office file - do not export it in outdated WMF format, export at least as EMF!

Or even better, Export as PDF and then convert PDF to EPS Level 2 as described in this answer of mine: most versions of MS Office can import EPS Level 2 files flawlessly and this format offers much better vector quality than even EMF! Although in some cases (like your example) you can directly Export to EPS from Mathematica and obtained file is already compatible with MS Office EPS Import Filter because it does not contain PostScript Level 3 instructions (but in more complicated cases you have to go through the PDF -> EPS Level 2 route).

Now about your specific case. When I Export your figure as WMF I obtain a 2 Mb file but when I Export it as EMF I obtain a 1 Mb file! When I embed the EMF file into a MS Office 2003 Word document I obtain a DOC file of size 30 Kb (try it yourself!). When I Export your figure as EPS I obtain a file of size 117 Kb, and when I embed it into a Word document I obtain a DOC file of size 68 Kb (try it yourself!). Do you need now any simplification of your figure? You already have everything in the best form!

And the last line: as it is correctly pointed out in the comment, NEVER use lossy JPG format for exporting line-art type graphics. With PNG format you obtain (in the most cases) smaller file size for such type of graphics WITH lossless quality.

| improve this answer | |
  • $\begingroup$ I do all of my annotation in powerpoint. Main reason being that I want to tweak things in place and not go back to mathematica to change a font size or something, but also because powerpoint's GUI drawing tools are better IMO. (I never actually "edit" the underlying graphics though) $\endgroup$ – george2079 Sep 11 '15 at 12:42
  • $\begingroup$ The file size issue is interesting, knowing nothing about the formats it make me think the WMF actually has somehow embedded the higher quality EMF data for apps that can use it. (The results look precisely the same on import to powerpoint.) $\endgroup$ – george2079 Sep 11 '15 at 13:46
  • $\begingroup$ I have had serious trouble with EPS import in Word. Most of the time the converter crashes in Word 2003. In Word 2010, the EPS file is inserted, but then the whole of Word crashes. I have stuck to EMF for this reason. (I still provide EPS files for the journals, who want them in this format anyway rather than embedded into the manuscript.) $\endgroup$ – Oleksandr R. Sep 11 '15 at 14:50
  • $\begingroup$ @OleksandrR. About compatibility of MS Office EPS Import Filter with different versions of EPS see this answer of mine. Sometimes it is necessary to distill EPS from Mathematica to another EPS file with PostScript Level 2. In such cases it is preferable to Export as PDF, then use pdftops as I describe in that answer. $\endgroup$ – Alexey Popkov Sep 11 '15 at 15:08
  • $\begingroup$ Thanks. I always use pdftops to produce the EPS files but I didn't know that Word can only deal with PostScript level 2. Unfortunately, that the EPS files are in CMYK color space is not negotiable for the journals, so maybe it will still not work, but I will try it anyway. I produce both EPS and EMF from the PDF source anyway, so it is not too much trouble to keep doing that if Word has problems. $\endgroup$ – Oleksandr R. Sep 11 '15 at 21:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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