Rank: 144 based on 350 downloads (last 30 days) and 5 files submitted
photo

John Iversen

E-mail

Personal Profile:
Professional Interests:

 

Watch this Author's files

 

Files Posted by John View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
14 Sep 2010 Published MATLAB Files freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen colormap, caxis, annotation, image, imagesc, index 334 81
  • 4.82759
4.8 | 59 ratings
20 Jul 2009 Screenshot FFTmtX Performs vectorized FFT on multiple processors. New: single and double precision. Author: John Iversen 6 2
05 Sep 2006 Screenshot Enhanced help--improve your workflow Simple enhancement to help listings: adds hyperlinks to open files for editing. Author: John Iversen development environme..., help, edit, hyperlink 3 4
  • 4.0
4.0 | 2 ratings
31 Aug 2006 Screenshot JISUBPLOT + NEXTPLOT: enhanced replacement for subplot Automatically create complex subplot layouts Author: John Iversen annotation, customization, subplot, figure, axis, layout 5 0
22 Jul 2005 Use Mac OS X XML Plists with MATLAB Utilities to convert Mac OS X native storage format (XML Property Lists) for use in MATLAB. Author: John Iversen data import, data export, xml, macintosh, parse, convert 2 0
Comments and Ratings by John View all
Updated File Comments Rating
05 Jan 2012 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen

== from the Author ==

Hi everyone. Happy New Year!

I wanted to belatedly comment on the problem people are having with eps/pdf exports ending up with pixellated text and lines. It's a bummer. Unfortunately, I believe this is an underlying feature of Matlab. Matlab has three methods for rendering plots, and this has an effect on printing to files, too. See "Impact of Rendering Method on the Output" at http://www.mathworks.com/help/techdoc/creating_plots/f3-103236.html#f3-103452

In short, even if you print to a vector format like 'eps' or 'pdf' matlab will save _bitmaps_! The only exception is when using render mode 'painters'. If you open these resulting eps/pdf in a vector program like Illustrator you'll see the file is in fact a bunch of bitmap 'strips'. It would be so much better if Matlab saved the image parts of your figure as bitmaps but kept the lines and text as crisp vectors. Please contact Mathworks to complain/suggest this.

=Workarounds=

First, try

>> set(gcf,'renderer','painters')

on your plots and see if you like the result. If so, you're golden: With the 'painters' renderer will you get what you want--a vector format output with text (and presumably lines--I haven't verified this) as vector objects. However, you will lose many effects like transparency, lighting, etc, and some more advanced plots you will see an error as they cannot be rendered in this mode.

Otherwise, the workaround is to specify a _resolution_ when you print to eps or pdf:

>> print(gcf,'-depsc','-r600','file.eps')

It'll still just output a bitmap, but at least the text and contours will be rendered smoothly (at 600 ppi in this case. Use a higher number for even smoother results). The default is in fact '-r72' which is why you have been getting pixellated text and lines.

In this case, there's really no point in printing to eps or pdf, so you might as well use 'tiff' or another true bitmap format:

>> print(gcf,'-dtiff','-r600','file.tiff')

I tested this out on Koos Spee's nice example, and using R2010a. Hopefully this generalizes and helps people out. Let me know if so/not. Thanks, John

PS. Thank you for bug fixes (Mircea & Subhaneil). I'll upload a new version eventually...

19 Nov 2010 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen

Thank you for the answer, Irene. Did it work?

Eef, this is not something I can reproduce. freezeColors doesn't touch the labels, so it is a side effect of some sort. It could be a matlab bug due to change in the figure's renderer--I see similar problems when converting (set(gcf,'renender',...) between rendering modes. If you can narrow it down to the specific line in freezeColors that causes the change, it could give you a clue on what to ask mathworks about.

Matthias: The example you give works fine here. What is the error you're seeing? If you're having a problem with cbfreeze, you'll have to ask its author for help.

Thanks.

14 Sep 2010 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen

Hello, I have uploaded a new version of freezeColors.

Changes: The main change is in documentation, finalizing the suggestion to use cbfreeze to freeze colorbars. There is also a fix to a problem in which caxis was changed in contourf plots.

I would enjoy hear about the kind of work users of this function are doing, and see examples of its use. (my email address is contained in the functions).

Thank you, John Iversen

07 Apr 2010 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen

====From the Author====

Hello everyone. I'm glad this function has been useful.

One noted problem is that freezeColors no longer works for colorbars. I am writing to say I have decided not to fix this because there is another function that solves the problem...

The problem:
In newer versions, Matlab reinitializes colorbars behind the scenes every time CAXIS or COLORMAP is called. This deletes the frozen colorbar, undoing the work of freezeColors. They're trying to be helpful...

A solution:
As noted above by David, there's an option that has worked for people, the function CBFREEZE by Carlos Adrian Vargas Aguilera. It is available at:

http://www.mathworks.com/matlabcentral/fileexchange/24371-colormap-and-colorbar-utilities-sep-2009

I don't think there's any point in reduplicating his good work, so I will update the description to recommend the following usage:

%EXAMPLE
subplot(1,2,1)
colormap hot
imagesc(peaks)
freezeColors %freezes plot's colors, as usual
colorbar
cbfreeze %freezes colors of any colorbars

subplot(1,2,2)
colormap jet
imagesc(peaks)
freezeColors
colorbar
cbfreeze

Please let me know if this works/doesn't work for you. I'll update the description and sample code at some point.

08 Oct 2009 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen

Fix for error pointed out by Daniel Armyr (11Aug): "image; freezeColors"

after the line: idx = cdata;
>insert the line: idx = floor(idx);

This will take care of the problem. Thanks for pointing it out.

Comments and Ratings on John's Files View all
Updated File Comment by Comments Rating
19 Jan 2012 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen Zhou

Thank you very much!!!!!!

05 Jan 2012 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen Iversen, John

== from the Author ==

Hi everyone. Happy New Year!

I wanted to belatedly comment on the problem people are having with eps/pdf exports ending up with pixellated text and lines. It's a bummer. Unfortunately, I believe this is an underlying feature of Matlab. Matlab has three methods for rendering plots, and this has an effect on printing to files, too. See "Impact of Rendering Method on the Output" at http://www.mathworks.com/help/techdoc/creating_plots/f3-103236.html#f3-103452

In short, even if you print to a vector format like 'eps' or 'pdf' matlab will save _bitmaps_! The only exception is when using render mode 'painters'. If you open these resulting eps/pdf in a vector program like Illustrator you'll see the file is in fact a bunch of bitmap 'strips'. It would be so much better if Matlab saved the image parts of your figure as bitmaps but kept the lines and text as crisp vectors. Please contact Mathworks to complain/suggest this.

=Workarounds=

First, try

>> set(gcf,'renderer','painters')

on your plots and see if you like the result. If so, you're golden: With the 'painters' renderer will you get what you want--a vector format output with text (and presumably lines--I haven't verified this) as vector objects. However, you will lose many effects like transparency, lighting, etc, and some more advanced plots you will see an error as they cannot be rendered in this mode.

Otherwise, the workaround is to specify a _resolution_ when you print to eps or pdf:

>> print(gcf,'-depsc','-r600','file.eps')

It'll still just output a bitmap, but at least the text and contours will be rendered smoothly (at 600 ppi in this case. Use a higher number for even smoother results). The default is in fact '-r72' which is why you have been getting pixellated text and lines.

In this case, there's really no point in printing to eps or pdf, so you might as well use 'tiff' or another true bitmap format:

>> print(gcf,'-dtiff','-r600','file.tiff')

I tested this out on Koos Spee's nice example, and using R2010a. Hopefully this generalizes and helps people out. Let me know if so/not. Thanks, John

PS. Thank you for bug fixes (Mircea & Subhaneil). I'll upload a new version eventually...

07 Dec 2011 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen Weiss, Nicolas

Nice script, but the fact that you cannot export eps files is a big downside. I found a workaround to this with the info posted here: http://www.mathworks.nl/support/tech-notes/1200/1215.html

Specifically, I wanted to plot a contour in the same axis as a gray scale image. This is an example of how to do this:

%Define the colormap
colormap([gray(64);jet(64)])

data = 255.*rand(100);
data2 = peaks(100);

h(1) = imagesc(data);
hold on
[C,h(2)] = contour(data2);
hold off

m = 64; % 64-elements is each colormap

cmin = min(data(:));
cmax = max(data(:));
C1 = min(m,round((m-1)*(data-cmin)/(cmax-cmin))+1);

cmin = min(data2(:));
cmax = max(data2(:));
C2 = min(m,round((m-1)*(data2-cmin)/(cmax-cmin))+1);
C2 = m+C2;

set(h(1),'CData',C1);
set(h(2),'ZData',C2);
 
caxis([min(C1(:)) max(C2(:))])

%Fix the color bar so that it only dispalys the colors of the contour
colorbar('YLim',[65,128],'YTickLabel',[10 20 30 40 50 60])

01 Dec 2011 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen Vincent

thanks!

17 Oct 2011 freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen Ionescu, Mircea

Great tool.
One issue: this function does not work with logical data.
Modifying line 196 from:
if ~isempty(g.CData) && (isnumeric(g.CData)|| islogical(g.CData)) && size(g.CData,3)==1,
to :
if ~isempty(g.CData) && isnumeric(g.CData) && size(g.CData,3)==1,

solves the issue.

Top Tags Applied by John
annotation, customization, figure, axis, caxis
Files Tagged by John View all
Updated   File Tags Downloads
(last 30 days)
Comments Rating
14 Sep 2010 Published MATLAB Files freezeColors / unfreezeColors Use multiple colormaps per figure! Version 2, now works for many types of objects, not only images. Author: John Iversen colormap, caxis, annotation, image, imagesc, index 334 81
  • 4.82759
4.8 | 59 ratings
05 Sep 2006 Screenshot Enhanced help--improve your workflow Simple enhancement to help listings: adds hyperlinks to open files for editing. Author: John Iversen development environme..., help, edit, hyperlink 3 4
  • 4.0
4.0 | 2 ratings
31 Aug 2006 Screenshot JISUBPLOT + NEXTPLOT: enhanced replacement for subplot Automatically create complex subplot layouts Author: John Iversen annotation, customization, subplot, figure, axis, layout 5 0
22 Jul 2005 Use Mac OS X XML Plists with MATLAB Utilities to convert Mac OS X native storage format (XML Property Lists) for use in MATLAB. Author: John Iversen data import, data export, xml, macintosh, parse, convert 2 0

Contact us at files@mathworks.com