0
votes

I wish to export figures both in eps and tiff (or png) using Matlab. Following this thread, I can change figure size and resolution conveniently. But now my problem is that the font sizes in my exported eps and tif files are very different.

For example:

1: using 300 dpi resolution to save a tif file:

r=300;
set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 1024*2 1024*2]/r)
print(gcf,'-dtiff',sprintf('-r%d',r), 'contour.tif');

I get a very small font size (same applies when saving to png and jpg) enter image description here

  1. Perhaps the resolution is affecting the font size. Because when I set r=0 (i.e. resolution the same as the display), the font size is very close to what I want:

    r=300; set(gcf, 'PaperUnits', 'inches', 'PaperPosition', [0 0 1024*2 1024*2]/r) print(gcf,'-dtiff',sprintf('-r%d',0), 'contour.tif');

enter image description here

But the problem is that such resolutions can not be published as zigzags. This can be seen when slightly zoomed in.

Just wondering how I can set all figure outputs to be consistent between formats, particularly between eps and tiffs, without using third party software (e.g. using Illustrator to export)?

1
There are numerous problems getting graphics out of MATLAB correctly. Have you tried export_fig on the File Exchange on The Mathworks website? - transversality condition
I understood this can be 'handled' by setting paperposition and resolution differently when saving to eps and fig to get exactly the same figure, but I am looking for the equation! I am now trying to use export_fig and will update if great results comes. - Chenming Zhang
I can't reproduce your problem. Please post a fully executable example, for both eps and tiff. - Robert Seifert
as @MichaelJ suggests, export_fig is the most downloaded File Exchange submission of all times, and there is a reason for that: IT works amazingly to export figures, way way way better than Matlab's inbuilt functions. In shot: You want to export figs? use export_fig! - Ander Biguri

1 Answers

0
votes

I found this problem is associated with the missing font in linux. I use the following commands to resolve three machines installing different distros:

for a ubuntu machine, run:

sudo apt-get install xfonts-75dpi xfonts-100dpi

for a gentoo machine, run:

emerge -av media-fonts/font-adobe-100dpi media-fonts/font-adobe-75dpi liberation-fonts

for a centos machine, run:

yum install xorg-x11-fonts-75dpi xorg-x11-fonts-100dpi

I have to reboot the computer to make the configuration in effect.