Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Please help me produce a nice .eps or .pdf using pcolor

491 views
Skip to first unread message

Dan Jones

unread,
Apr 22, 2010, 12:55:21 PM4/22/10
to
Hi all,

I'm using pcolor (with interpolated shading) to create a figure. My goal is to then use Adobe Illustrator (CS3) to produce a publication-quality graphic.

The figure that Matlab produces looks great, but once I save the image in EPS or PDF format, the quality goes down considerably. The image is crisscrossed with white lines that form triangular polygons. I guess those are the primitive objects that were used to draw these particular vector graphic images. Unfortunately, it looks awful.

I've tried saving the Matlab output in Illustrator format and then opening this file in illustrator, but the results are terrible - the image looks very blocky. Saving the Matlab output as a bitmap doesn't seem to work, either. The quality is too low.

Is this just a data resolution problem? That is, should I try and get data that is better resolved before plotting this image? Any suggestions are very welcome!

Oliver Woodford

unread,
Apr 22, 2010, 6:34:20 PM4/22/10
to
"Dan Jones" <Daniel...@colostate.edu> wrote in message <hqpv1p$hi$1...@fred.mathworks.com>...

Try to produce publication quality bitmaps direct from Matlab using export_fig from the FEX.

Vinesh Rajpaul

unread,
Jul 12, 2010, 5:22:04 PM7/12/10
to
Hi -

The problem you mentioned (the "white crisscrossed lines") frustrated the hell out of me for a while. As far as I can tell, the problem lies not with MATLAB's image rendering but rather with the anti-aliasing routine used in most PDF/EPS viewers. In other words the output from MATLAB is fine but the PDF viewer is not rendering the image correctly. If you can find a way to turn the anti-aliasing (in your PDF/EPS viewer) off, I think the problem will likely go away. E.g. if you are using Adobe Reader: go to Preferences > Page Display > disable the "smooth line art" setting. This sorted out the issue for me!

"Dan Jones" <Daniel...@colostate.edu> wrote in message <hqpv1p$hi$1...@fred.mathworks.com>...

Chris

unread,
Jul 28, 2011, 4:18:11 PM7/28/11
to
I spent some time dealing with this problem today and I couldn't figure out how to change the anti-aliasing (I'm using Inkscape, maybe there's a way to do it?). Eventually I stumbled on a simple but not very elegant solution:

1. open the .eps file
2. ungroup everything: after 3-4 ungroups I had it down to a layer in which all of the triangles can be selected with a single click.
3. copy the triangles and paste in place a couple times. The lines get fainter and disappear eventually.


"Vinesh Rajpaul" wrote in message <i1g11s$jt9$1...@fred.mathworks.com>...

Wardo

unread,
Dec 3, 2011, 8:06:09 PM12/3/11
to
This is a nice little workaround.

If you have Microsoft PowerPoint, it views it properly!

So save your pcolor figure to *.eps.

Then drag it into PowerPoint. In PowerPoint, right click the imported picture and Save As as PDF.

Illustrator can then open this, and the lines are gone!

~Ward

Dan

unread,
Mar 2, 2012, 4:43:28 PM3/2/12
to
This problem has been bugging me for years! Finally, due to this thread, I have it fixed. In Illustrator go to Preferences > General, and deselect Anti-aliased Artwork. Finally!! Thanks, All.

Image Analyst

unread,
Mar 2, 2012, 6:43:29 PM3/2/12
to
"Dan" wrote in message <jireu0$71g$1...@newscl01ah.mathworks.com>...
> This problem has been bugging me for years! Finally, due to this thread, I have it fixed. In Illustrator go to Preferences > General, and deselect Anti-aliased Artwork. Finally!! Thanks, All.
--------------------------------------------------------------
The problem that's been bugging me for years is why anyone would ever want to use pcolor in the first place since it's so deceiving in that it has one less square in each direction than the number of elements in your array and the colors in it don't correspond to your array values. I've asked many times but have never gotten an answer of any kind.

Demis

unread,
Mar 13, 2012, 10:38:12 AM3/13/12
to
Unfortunately, if the problem lies in every viewer's default anti-aliasing settings, then you would guess that inserting the Matlab PDF of a surf() plot into a publication will have white lines all over it for almost all readers of your paper!

It doesn't really help for only you to remove the lines - unless a subsequent "Export > *.TIFF" does in fact remove the lines. It would have been nice to retain the PDF format though, for zoomability.

plainwhite

unread,
Aug 29, 2013, 5:36:12 PM8/29/13
to
"Demis " <x...@z.org> wrote in message <jjnm4k$bi8$1...@newscl01ah.mathworks.com>...
> Unfortunately, if the problem lies in every viewer's default anti-aliasing settings, then you would guess that inserting the Matlab PDF of a surf() plot into a publication will have white lines all over it for almost all readers of your paper!
>
> It doesn't really help for only you to remove the lines - unless a subsequent "Export > *.TIFF" does in fact remove the lines. It would have been nice to retain the PDF format though, for zoomability.

Well, even if this comes late it might be of some use.
In my view the anti-aliasing problem is just the symptom while there is a more general issue how rectangular pcolor tiles are saved in EPS. For each rectangle, Matlab combines two triangular tiles. If triangular tiles are replaced by proper rectangular ones, the diagonal and most likely all other aliasing artifacts are removed.
I wrote a little file that changes the EPS file accordingly.

See file exchange
http://www.mathworks.com/matlabcentral/fileexchange/43271-pcolor-eps-fix

Cheers

Jonathan Lauderdale

unread,
May 15, 2014, 1:43:08 PM5/15/14
to
"Chris" wrote in message <j0sg63$jpi$1...@newscl01ah.mathworks.com>...
> I spent some time dealing with this problem today and I couldn't figure out how to change the anti-aliasing (I'm using Inkscape, maybe there's a way to do it?). Eventually I stumbled on a simple but not very elegant solution:
>
> 1. open the .eps file
> 2. ungroup everything: after 3-4 ungroups I had it down to a layer in which all of the triangles can be selected with a single click.
> 3. copy the triangles and paste in place a couple times. The lines get fainter and disappear eventually.
>
>

Hello,
Sorry to resurrect this thread, but I've had to tackle this issue today and thought I'd share my experience. Unfortunately the "fix_pcolor_eps" method took far too long to be useful for the number of segments that needed merging (global ocean/land masking) so this is a post-process fix:

1.) Make sure output is a true vector image printed using the "painters" renderer rather than "zbuffer" using "set(gfc,'renderer','painters')" on a per figure basis or "set(0, 'DefaultFigureRenderer', 'painters')" for a more permanent change in your startup.m (HT http://www.mathworks.com/matlabcentral/newsreader/view_thread/80689)

2.) Open in Inkscape (although I'm pretty sure other tools like Illustrator will have similar options) and ungroup subfigures and axes, until you can select the pcolor elements as one entire block.

For each set of colors represented as diagonal elements:
3.) Hover the "Dropper" tool over the pcolor block, or even the legend, to get the element's color as a hex number preceded by a # (see it in the toolbar, eg red is #ff0000, green is #00ff00 and blue is #0000ff).

4.) With the pcolor layer selected, use the "Find" tool (Edit > Find, or Ctrl+F) to find all the elements of the color found in step 3. To do this for red elements, enter "fill:#ff0000" in the "Style" text box and check "Search in selection". Alternatively you could have added a new Inkscape layer, moved just the pcolor section and checked "Search in current layer" instead. Hit "Find" to select all the elements in the selection/layer that are red.

5.) Use Path > Combine (or Ctrl+K) to merge the selected elements into one, thus removing all the nasty antialiasing effects where the background bleeds through the adjacent elements of the same color.

Hope this helps,
Jon

Chris Ford

unread,
Aug 13, 2015, 7:06:14 PM8/13/15
to
"Dan Jones" wrote in message <hqpv1p$hi$1...@fred.mathworks.com>...
I noticed that multiple plots on a figure do not have this problem. So for a single plot I just created another dummy plot off the edge of the figure, and that works fine!
eg for a pcolor or surf:
axes('Position',[1.1 0.9 0.05 0.05],'Units','normalized');
h=findobj(gca,'Type','Surface');
Z=get(h(1),'ZData');% get some z data
pcolor(Z);% put a plot off the figure so Matlab generates a PDF without the antialiasing problem

I am using Matlab R2015a.
I hope this works for others.
Chris.
0 new messages