Comments on: Using multiple colormaps in a single figure https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/?s_tid=feedtopost Jiro and Sean share favorite user-contributed submissions from the File Exchange. Wed, 25 Jan 2012 10:27:49 +0000 hourly 1 https://wordpress.org/?v=6.2.2 By: Pascale https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-14403 Wed, 25 Jan 2012 10:27:49 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-14403 Thanks a lot for this awesome code!

]]>
By: Pedro https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13759 Fri, 13 Aug 2010 01:11:12 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13759 Dear all,

I would like to paint N cylinders, each cylinder [in the same figure] with its own color map, according to an intensity function. Is it possible to do it with these cool freeze functions? [In my plot, the cylinders are always identical even if they have different intensities]

thanks,

Pedro

]]>
By: Brett https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13555 Fri, 14 May 2010 16:03:35 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13555 Cecilia,
If I recall correctly, John provided a way to do that:

h=colorbar; freezeColors(h)

…or simply: freezeColors(colorbar).

Or, take a look at Carlos’s very useful comment his CBFREEZE function, above.
Cheers,
Brett

]]>
By: Cecilia Fleeger https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13554 Fri, 14 May 2010 15:45:53 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13554 How to add colorbars for corresponding images in single figure window?

]]>
By: Mark https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13414 Mon, 01 Feb 2010 11:48:40 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13414 Very nice function, indeed, thanks for that. But why does’t MATLAB freeze the colormaps for subplots automatically?

]]>
By: Igor https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13218 Mon, 03 Aug 2009 20:50:18 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13218 Very useful and fit-to-practice solution. Thanks.

]]>
By: Igor https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13217 Mon, 03 Aug 2009 20:50:12 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13217 Very useful and fit-to-practice solution. Thanks.

]]>
By: Carlos Adrian Vargas Aguilera https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13211 Thu, 30 Jul 2009 20:41:13 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13211 Yes, this is a very useful contribution by John. By the way, to freeze the colorbar you can use my CBFREEZE:

% DATA
load clown;
load penny.mat

% FIGURE
figure('color','w')

subplot(1,2,1)
image(X);
colormap(map);
cbfreeze   % --------------> FREEZE COLORBAR
% Here's John's contribution:
freezeColors

subplot(1,2,2)
contour(P,15)
colormap(copper)
axis ij square
pcolor(P)
axis ij square
shading flat
colorbar

Download it here:
https://www.mathworks.com/matlabcentral/fileexchange/24371-colormap-and-colorbar-utilities–jul-2014-

Cheers, Carlos

]]>
By: Jody Klymak https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13210 Thu, 30 Jul 2009 16:33:25 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13210 I love this entry too, and had my own kludges for years to make it happen, but Iverson’s solution is much more elegant.

It is unfortunate that this requires a workaround to include colorbars. I actually don’t understand the logic behind the new way the colorbar class is implemented. I love how you can place the colorbars, but having them redraw everytime a new graphic element is added seems unnecessary.

Of course all this fudging could be solved if colormaps were associated with axes rather than figures. It really seems like a holdover from the days when graphics cards couldn’t handle more than 256 colors. Seems like a simple change that would be easily backwards compatible.

]]>
By: Andrew https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13209 Wed, 29 Jul 2009 18:53:47 +0000 https://blogs.mathworks.com/pick/2009/07/24/using-multiple-colormaps-in-a-single-figure/#comment-13209 I have used and like freezeColors. It might be worth noting that the trick that freezeColors uses is to convert the color values to rgb…that way the colormap of the figure no longer applies. Once you know that, there are several tools to get multiple colormaps on the same figure or axes. I like to use Oliver Woodford’s FEX submission, SC (https://www.mathworks.com/matlabcentral/fileexchange/16233-sc-powerful-image-rendering) to convert indexed images as well as cdata for surf plots into RGB. Here is a simple example:

[x,y,z]=peaks(50);

zpos=z;
zpos(z<=0)=NaN;
zrgb=sc(zpos,'hot');

figure
sh(1)=surf(x,y,z);
hold on
sh(2)=surf(x,y,zpos,zrgb);
set(sh,'edgecolor','none')
]]>