3

I am currently using the excellent script *export_fig* to export figures from MATLAB for use in a journal paper I am writing. This file works perfectly for raster images (bmp, tiff, etc) but I really want to export my figures to a vector format. I have 2 options, eps or pdf. Exporting to pdf is fine but when I export to eps, I notice that all the font in the figure (axes labels, legend font) appears to be thickened somewhat. This isnt the case when I export to pdf so I have no idea why it is happening, hopefully someone has come across this issue before?

I have tried changing the default font before exporting but the issue persists. Also, and interestingly, when I open the exported figure in pdf format it looks fine, but when I publish it from pdf to eps using Adobe Acrobat Pro, the same problem occurs. The resultant eps now has thickened fonts (a bit like the font is in bold).

Any help would be appreciated.

Sanka
  • 177
  • 1
  • 4
  • I've been experiencing the same kind of bugs when working with `export_fig`. Best solution I have found so far is to try working with Matlab default fonts only, a list of these can be found here: http://www.math.ufl.edu/help/matlab/tec2.6.html – Fraukje Sep 17 '13 at 09:35
  • As far as I know I am just using the default "Helvetica" font. It's strange because when I open the exported .eps file in Ghostview or Ghostscript, it looks fine. When I open it in Illustrator the font appears bold. And finally, when I insert the .eps into word, the font appears as it was in Illustrator (with bold-esque font). – Sanka Sep 17 '13 at 09:51
  • Well `export_fig` has a lot of bugs like that which are hard to solve or even to work around. Would it be an option to use pdf instead of eps? – Fraukje Sep 17 '13 at 11:32
  • I guess it has nothing to do with Matlab, but with the renderer of Acrobat. I had similar problems in the past, don't know the solution anymore, but it was tricky, you had to change something deep in the preferences of Acrobat. So I just saved all my figures as pdf (post-processed them in Illustrator) and used them in Latex. What do you need eps for? For example in Latex pdf-figures just work fine, while eps always makes trouble. – Robert Seifert Sep 17 '13 at 13:49
  • Thanks for the feedback. It's not that I specifically need eps format, just need the figures in vector format really so pdf so should do fine. I need them in vector format as I am writing a journal paper and raster images won't do. However, as far as I know I dont think it is possible to insert pdf figures into Word? I know LyX (or Latex) happily accepts pdf figures but the journal is looking for Word format! – Sanka Sep 17 '13 at 15:37
  • @thewaywewalk By any chance you don't remember how you resolved the issue? I have been looking through many forums and the issue seems to be quite common but no one has explicitly stated some kind of solution. My thinking is if I could somehow import the Helevetica font (used by MATLAB's postscript) into Illustrator, then Illustrator would not automatically have to change the font when opening the eps file? – Sanka Sep 17 '13 at 23:02
  • I had similar issues when working on this. Try these: 1) Test on a font that is accessible via inkscape/illustrator 2) in eps convert to a high resolution image (larger than intended image size). I remember batch converting eps2png to save high res images. A solution like that should satisfy journal requirements. 3) I have a memory of a setting in export_fig/matlab that changed output behaviour. Something like setpapermode(manual). It set the save to be faithful without post-edits? Sorry, I can't remember well enough. – Cosades Sep 30 '13 at 12:41
  • I finally found a way to resolve the issue. It appears that the issue is not really due to MATLAB but arises because of the way in which the postscript editor in Adobe Illustrator interprets the fonts from MATLAB. Alternatively, if I open the eps file in Inkscape the image appears exactly as I want it to (no font issues). I believe the reason for this is because Inkscape uses Ghoscript as its interpreter which doesnt have any problems with the MATLAB fonts. – Sanka Oct 24 '13 at 09:25

2 Answers2

1

I have found the best way to export a vector image is to use the Metafile format which is a true vector format. The pdf file you get when you use the print command shows compression artifacting when you zoom in.

Here are 3 options for putting a Metafile into PowerPoint or Word:

  1. In the Matlab figure window, select Edit / Copy Figure from the menu, then paste into Word, PowerPoint, Outlook, etc. For line graphs, I usually make the lines thicker before copying, you can do this by selecting Edit / Copy Options, then select "Figure Copy Template" on the left side of the dialog box, then click on the "Power Point" button, then click on "Apply to Figure".

  2. You can use this command to copy the Metafile to the clipboard print -dmeta, then paste into Word, PowerPoint, etc.

  3. You can write the metafile to disk, then you can just drag and drop the file from Windows Explorer onto a PowerPoint slide or from the Insert Ribbon, select "file" and pick the appropriate .emf file. To write the emf file to your disk, give a command like this: print('-dmeta', 'myfile')

This will create a file called "myfile.emf" on your hard disk.

outdoor_guy
  • 146
  • 4
1

I faced the same issue in all versions of matlab. I always get a different font in the exported eps file.

So here is one method i use each time.

Save a MATLAB fig file with the formatting you want for different elements e.g labels etc. Export eps/pdf from this and verify if it is ok for you.

Now the simple trick is to execute your program without plotting figures.

1) Import the above mentioned saved fig file in to matlab and open plot editor. 2) Delete its variables from plot brower 3) Import your variables which you want to plot (click on figure and then click add data tab in plot brower) 4) update label and title (text only, no font changes) 5) Save file as .fig and also export to eps.

You are done and you get the same formatting in each figure you generate like this.

It is a time consuming process but gets your job done. Also in case you want the formatting of a fig file saved with other version of MATLAB this method works, even if OS is changed or fonts are upgraded.

Astro
  • 229
  • 2
  • 12