Posted by: baryonic | December 29, 2010

Vector plots, pcolor, MATLAB, and you

I make most of my figures in MATLAB, using the print -depsc command. This generates lovely, vectorized figures for most incantations of plot and its cousins, but annoyingly returns bitmap graphics if you use that command on plots involving pcolor. If you want vectorized .eps files with your colormap rendered nicely rather than .eps figures containing bitmaps, use the -painters flag (it’s a type of Renderer) while printing (thanks, MATLAB Central):

print -depsc -painters file.eps

Now that you have a vector image containing your colormap information, it’s time to display your figure. On some systems, your PS/PDF renderer will insert some crisscrossing white lines while rendering your vectorized image. However, you can usually turn off anti-aliasing on your viewer and you should be to witness your glorious figures sans white crosshatching (again, thanks to MATLAB Central).

Sure, I could probably tackle these problems in Adobe Illustrator or Inkscape, but I like having things work properly on the first go when it comes to creating figures and otherwise minimizing the number of non-automated steps in my image-creation workflow.

(PS: a draft of my thesis is available here.)

About these ads

Responses

  1. Thank you for this post, it has been very helpful for me. I would like to comment how I managed to get a good .eps image of a pcolor plot using ‘saveas’ command instead of ‘print’.

    When you use ‘saveas(figure,’filename.eps’,’epsc’)’ (‘epsc’ must be written to preserve colors), you cannot use ‘-painters’ as an input argument. But there is a little trick to be able to do this. You must open the m-file called ‘saveas.m’, and, in one of the last lines, where you see ‘print( h, name, ['-d' dev{i}])’, write ‘print( h, name, ['-d' dev{i}], ‘-painters’ )’ instead. Save changes in the file ‘saveas.m’ (or save this modified program with other name, like ‘newprogram.m’). Then, when you use ‘saveas(figure,’filename.eps’,’epsc’)’ (or ‘newprogram(figure,’filename.eps’,’epsc’)’), you will get a good looking figure (vectorial, not bitmap), which is very useful if you are used to work with ‘saveas’ but not with ‘print’.

    Cheers,

    Ángel Gutiérrez Rubio.

    • Hi Ángel,

      Thanks for the comment, and for the “saveas” trick. I’ll definitely take a look at that in the future.

      Sondy


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: