Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
export figure on mac

Subject: export figure on mac

From: jonathan.rubin@gmail.com

Date: 7 Apr, 2007 02:46:51

Message: 1 of 19

hi experts,
  when exporting images (e.g, imagesc(rand(5)) ) to PDF or EPS formats
(using 'print' command or 'save as...' from the figure menu) on a mac
platform, the output gets very blurry.
when using non-vector-formats (JPG, BMP, etc...) the problem
disappears.
following the same procedure on linux-platform or windows-platform -
no problem at all.

so, how can I export non-blurry EPS/PDF figures on a mac ?

Subject: export figure on mac

From: Chris

Date: 29 May, 2009 03:54:02

Message: 2 of 19

I'm having the same problem and am hoping this can get fixed. One not-so-great alternative is to use pcolor instead of imagesc, but this has known problems of its own. (e.g. see this link about the diagonal white lines problem: http://www.mathworks.co.kr/matlabcentral/newsreader/view_thread/169966).

So, Matlab gurus: Does anyone know how to export vector graphics color plots on a mac without the blurriness caused by imagesc or the white diagonal lines caused by pcolor?

Thanks!

Chris

jonathan.rubin@gmail.com wrote in message <1175939211.290594.138990@o5g2000hsb.googlegroups.com>...
> hi experts,
> when exporting images (e.g, imagesc(rand(5)) ) to PDF or EPS formats
> (using 'print' command or 'save as...' from the figure menu) on a mac
> platform, the output gets very blurry.
> when using non-vector-formats (JPG, BMP, etc...) the problem
> disappears.
> following the same procedure on linux-platform or windows-platform -
> no problem at all.
>
> so, how can I export non-blurry EPS/PDF figures on a mac ?
>

Subject: export figure on mac

From: Oliver Woodford

Date: 29 May, 2009 14:39:01

Message: 3 of 19

"Chris" wrote:
> So, Matlab gurus: Does anyone know how to export vector graphics color plots on a mac without the blurriness caused by imagesc or the white diagonal lines caused by pcolor?

You could try export_fig:
http://www.mathworks.com/matlabcentral/fileexchange/23629
It normally gives good results when exporting to pdf or eps (especially when image compression causes artifacts), though you need ghostcript and xpdf installed.

Let us know if it helps,
Oliver

Subject: export figure on mac

From: Chris

Date: 29 May, 2009 21:19:01

Message: 4 of 19

No, unfortunately that doesn't work either... My .pdfs still have the blurriness with imagesc and the white diagonal lines with pcolor.

Chris

"Oliver Woodford" <o.j.woodford.98@cantab.net> wrote in message <gvos25$cms$1@fred.mathworks.com>...
> "Chris" wrote:
> > So, Matlab gurus: Does anyone know how to export vector graphics color plots on a mac without the blurriness caused by imagesc or the white diagonal lines caused by pcolor?
>
> You could try export_fig:
> http://www.mathworks.com/matlabcentral/fileexchange/23629
> It normally gives good results when exporting to pdf or eps (especially when image compression causes artifacts), though you need ghostcript and xpdf installed.
>
> Let us know if it helps,
> Oliver

Subject: export figure on mac

From: WhyDoIDoThis

Date: 18 Jun, 2009 08:27:24

Message: 5 of 19

On May 29, 5:19 pm, "Chris " <cs...@princeton.edu> wrote:
> No, unfortunately that doesn't work either... My .pdfs still have the blurriness with imagesc and the white diagonal lines with pcolor.
>
> Chris
>
> "Oliver Woodford" <o.j.woodford...@cantab.net> wrote in message <gvos25$cm...@fred.mathworks.com>...
> > "Chris" wrote:
> > > So, Matlab gurus: Does anyone know how to export vector graphics color plots on a mac without the blurriness caused by imagesc or the white diagonal lines caused by pcolor?
>
> > You could try export_fig:
> >http://www.mathworks.com/matlabcentral/fileexchange/23629
> > It normally gives good results when exporting to pdf or eps (especially when image compression causes artifacts), though you need ghostcript and xpdf installed.
>
> > Let us know if it helps,
> > Oliver
>
>

Hi guys,

I'm having the same white line problems? Do you find any solutions?

Ken

Subject: export figure on mac

From: Ryan Webb

Date: 16 Feb, 2010 23:33:02

Message: 6 of 19

Same problem here, in addition the figure is cropped on the left and right. This has been an ongoing problem dating back to at least 2008a. Any word on this??

Subject: export figure on mac

From: Jonas

Date: 17 Feb, 2010 02:41:06

Message: 7 of 19

"Ryan Webb" <webbr@econ.donotinclude.queensu.ca> wrote in message <hlf9ve$euq$1@fred.mathworks.com>...
> Same problem here, in addition the figure is cropped on the left and right. This has been an ongoing problem dating back to at least 2008a. Any word on this??

I get the same problem on Snow Leopard with 2010a - saving to eps looks horrible.

However, export_fig solves the issue for me (note that it crops the figure tightly, but I like that a lot).

Subject: export figure on mac

From: Jonas

Date: 17 Feb, 2010 03:12:06

Message: 8 of 19

"Jonas" <remove_this_iop@gmx.at> wrote in message <hlfl02$bv1$1@fred.mathworks.com>...
> "Ryan Webb" <webbr@econ.donotinclude.queensu.ca> wrote in message <hlf9ve$euq$1@fred.mathworks.com>...
> > Same problem here, in addition the figure is cropped on the left and right. This has been an ongoing problem dating back to at least 2008a. Any word on this??
>
> I get the same problem on Snow Leopard with 2010a - saving to eps looks horrible.
>
> However, export_fig solves the issue for me (note that it crops the figure tightly, but I like that a lot).

Oops, I wrote too soon. Export_fig works only if saving to pdf, not when saving to eps. However, pdf is fine if you want to edit the figure later, e.g. in Illustrator.

Subject: export figure on mac

From: Oliver Woodford

Date: 17 Feb, 2010 16:58:21

Message: 9 of 19

"Chris" wrote:
> No, unfortunately that doesn't work either... My .pdfs still have the blurriness with imagesc and the white diagonal lines with pcolor.

Bluriness of images when viewing pdfs (or eps files, for that matter) is generally caused by the viewing (or printing) software bilinearly interpolating the colors of an image when magnifying it to screen resolution. I've had 4 prints of my thesis ruined because of this.

There are two ways to avoid it:
1. Change the interpolation settings in your viewing/printing software, or change to a software that doesn't interpolate.
2. Increase the resolution of your image by, say, 8 (for good jpeg compression) before generating the figure, using nearest neighbor interpolation.

Method 2 is failsafe because it doesn't matter what viewing/printing software anyone else has, the figure will still look right to them too.

HTH,
Oliver

Subject: export figure on mac

From: nick.steinmetz

Date: 22 Feb, 2010 22:28:35

Message: 10 of 19

On Feb 16, 7:12 pm, "Jonas" <remove_this_...@gmx.at> wrote:
> "Jonas" <remove_this_...@gmx.at> wrote in message <hlfl02$bv...@fred.mathworks.com>...
> > "Ryan Webb" <we...@econ.donotinclude.queensu.ca> wrote in message <hlf9ve$eu...@fred.mathworks.com>...
> > > Same problem here, in addition the figure is cropped on the left and right. This has been an ongoing problem dating back to at least 2008a. Any word on this??
>
> > I get the same problem on Snow Leopard with 2010a - saving to eps looks horrible.
>
> > However, export_fig solves the issue for me (note that it crops the figure tightly, but I like that a lot).
>
> Oops, I wrote too soon. Export_fig works only if saving to pdf, not when saving to eps. However, pdf is fine if you want to edit the figure later, e.g. in Illustrator.

For me, export_fig didn't even work saving to .pdf (to get rid of
lines), but on a whim I wondered whether the white/gray lines would
actually be there in the printed version (or whether they were just an
artifact of the display) and lo and behold the printed version looks
beautiful. If your application requires a nice electronic document
then this doesn't help you at all, but if you only need a printed
version (I am putting the pcolor image on a poster) then just try
printing it!

To be clear, I am using Matlab R2009b on Windows 7 (I know this post
was about macs, but I don't think the problem was specific to mac. but
sorry if this fails entirely there.). I export the pcolor figure using
-painters renderer; nothing else fancy.

Hope that helps,

Nick

Subject: export figure on mac

From: Jan Simon

Date: 22 Feb, 2010 22:57:02

Message: 11 of 19

Dear WhyDoIDoThis!

> I'm having the same white line problems? Do you find any solutions?

For me it helped to fix the surface normals:
  http://www.mathworks.co.kr/matlabcentral/fileexchange/23882-surfo

Please read this - antialiasing in the PDF viewer *must* create white lines on the screen:
  http://www.mathworks.co.kr/matlabcentral/newsreader/view_thread/268653

Kind regards, Jan

Subject: export figure on mac

From: Oliver Woodford

Date: 23 Feb, 2010 10:58:03

Message: 12 of 19

"nick.steinmetz" wrote:
> For me, export_fig didn't even work saving to .pdf (to get rid of
> lines).

Nick,
The white lines, as with the blurry images, are artifacts of the pdf viewing software you're using (and its options settings), not the pdf file itself. See Jan's comment above.
Regards,
Oliver

Subject: export figure on mac

From: Daniel

Date: 25 Mar, 2010 15:58:05

Message: 13 of 19

jonathan.rubin@gmail.com wrote in message <1175939211.290594.138990@o5g2000hsb.googlegroups.com>...
> hi experts,
> when exporting images (e.g, imagesc(rand(5)) ) to PDF or EPS formats
> (using 'print' command or 'save as...' from the figure menu) on a mac
> platform, the output gets very blurry.
> when using non-vector-formats (JPG, BMP, etc...) the problem
> disappears.
> following the same procedure on linux-platform or windows-platform -
> no problem at all.
>
> so, how can I export non-blurry EPS/PDF figures on a mac ?
>

Try using print with the '-opengl' (or '-zbuffer') option or changing the figure renderer to opengl or zbuffer before doing the saveas commnad. It worked for me on Mac 10.5.8, Matlab 2010a.

So, the commands would be either
print(gcf,'filename','-depsc','-opengl')

or
set(gcf,'renderer','opengl')
saveas(gcf,'filename','epsc')

It seems that the painters renderer is not playing nicely with epsc or pdf.

Subject: export figure on mac

From: Kevin

Date: 5 Jul, 2010 22:14:04

Message: 14 of 19

"Daniel " <noname@noemail.com> wrote in message <hog16c$l37$1@fred.mathworks.com>...
> jonathan.rubin@gmail.com wrote in message <1175939211.290594.138990@o5g2000hsb.googlegroups.com>...
> > hi experts,
> > when exporting images (e.g, imagesc(rand(5)) ) to PDF or EPS formats
> > (using 'print' command or 'save as...' from the figure menu) on a mac
> > platform, the output gets very blurry.
> > when using non-vector-formats (JPG, BMP, etc...) the problem
> > disappears.
> > following the same procedure on linux-platform or windows-platform -
> > no problem at all.
> >
> > so, how can I export non-blurry EPS/PDF figures on a mac ?
> >
>
> Try using print with the '-opengl' (or '-zbuffer') option or changing the figure renderer to opengl or zbuffer before doing the saveas commnad. It worked for me on Mac 10.5.8, Matlab 2010a.
>
> So, the commands would be either
> print(gcf,'filename','-depsc','-opengl')
>
> or
> set(gcf,'renderer','opengl')
> saveas(gcf,'filename','epsc')
>
> It seems that the painters renderer is not playing nicely with epsc or pdf.

It is important to note that painters is the only vector renderer supported by Matlab which "Cannot render figures that use RGB color for patch or surface objects." Also, raster eps files have a whole new set of problems (both opengl and zbuffer can only make raster images).

(See http://www.mathworks.com/access/helpdesk/help/techdoc/creating_plots/f3-84337.html#f3-102410)

Subject: export figure on mac

From: Christopher Hummersone

Date: 31 Oct, 2012 16:22:08

Message: 15 of 19

All these years later and I still have this problem!

Anyway, as Oliver points out, this problem is due to the way OS X's Preview.app (and its derivatives such as TeXShop's preview) renders the files, rather than problems in the files themselves. I find the figures look different in Acrobat, and that this representation is truer to how the figure is printed.

That said, I noticed that one figure I produced recently, with imagesc, rendered the plot as a series of objects rather than as a bitmap. Consequently it looks good in Preview and Acrobat. I'm still trying to figure out how I did it...

Chris

Subject: export figure on mac

From: Christopher Hummersone

Date: 31 Oct, 2012 19:47:08

Message: 16 of 19

I think I'm getting to the root of the problem I describe above. Compare these outputs (requires Oliver's export_fig: http://www.mathworks.com/matlabcentral/fileexchange/23629):

%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 256; % size of colormap
% N = 258; % compare with this value

figure('units','inches','position',[6,6,7,3.5],'color','w')
colormap((gray(N)))
C = N.*rand(16,50);
x = linspace(0,1,size(C,1));
y = linspace(0,1,size(C,2));
image(x,y,C)
colorbar

export_fig('fig_export_fig.eps','-eps','-gray',gcf)
print(gcf,'fig_print.eps','-deps')
%%%%%%%%%%%%%%%%%%%%%%%%%%

On my computer (Mac OS X 10.6.8)...
With N=256
print: <image> portion is rendered as bitmap
export_fig: <image> portion is rendered as bitmap
With N=258
print: <image> portion is rendered as bitmap; incorrect colorbar (white -> red)
export_fig: <image> pixels become objects

Weird!

Subject: export figure on mac

From: Christopher Hummersone

Date: 1 Nov, 2012 12:49:08

Message: 17 of 19

Well repeating the test this morning, and the white->red colorbar problem no longer seems to occur. It seems that export_fig will render image/imagesc as vectors rather than bitmaps if the colormap length is greater than 256.

Subject: export figure on mac

From: Colin

Date: 27 Feb, 2013 14:27:08

Message: 18 of 19

"Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <k6rj7g$8qn$1@newscl01ah.mathworks.com>...
> Anyway, as Oliver points out, this problem is due to the way OS X's Preview.app (and its derivatives such as TeXShop's preview) renders the files, rather than problems in the files themselves. I find the figures look different in Acrobat, and that this representation is truer to how the figure is printed.

Exactly. The problem with white lines appearing between vector elements in OS X Preview is due to its built-in antialiasing for vector graphics.

Go to Preview preferences and turn off "smooth text and line art". Vector graphics will render as in Acrobat. Works in OS X 10.6 at least.

Subject: export figure on mac

From: Mykola

Date: 18 Oct, 2013 05:14:07

Message: 19 of 19

"Colin " <c_r_buchanan@yahoo.com> wrote in message <kgl53s$l29$1@newscl01ah.mathworks.com>...
> "Christopher Hummersone" <christopher.hummersone@surrey.ac.uk> wrote in message <k6rj7g$8qn$1@newscl01ah.mathworks.com>...
> > Anyway, as Oliver points out, this problem is due to the way OS X's Preview.app (and its derivatives such as TeXShop's preview) renders the files, rather than problems in the files themselves. I find the figures look different in Acrobat, and that this representation is truer to how the figure is printed.
>
> Exactly. The problem with white lines appearing between vector elements in OS X Preview is due to its built-in antialiasing for vector graphics.
>
> Go to Preview preferences and turn off "smooth text and line art". Vector graphics will render as in Acrobat. Works in OS X 10.6 at least.

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us