how to set the range of colorbar

  • Follow


hello guys,

i have a matrix:
-------------------------------------------------
a= 2.3  1.7  3.3
    4.1  4.4  9.7
    1.4  5.7  8.1
-------------------------------------------------
and i have used "pcolor" to draw this figure as:
------------------------------------------------
h=pcolor(a);
set(h,'LineStyle','none');
axis image
colorbar 
-------------------------------------------------
the range colorbar will be set automatically in this case (from 1 to 10).
question is: is it possible that i can set or define this range like from 1 to 20 in this case.

thanks,
james
0
Reply James 10/8/2010 8:28:05 AM

"James Waage" <again@hotmail.de> wrote in message <i8mkml$age$1@fred.mathworks.com>...
> hello guys,
> 
> i have a matrix:
> -------------------------------------------------
> a= 2.3  1.7  3.3
>     4.1  4.4  9.7
>     1.4  5.7  8.1
> -------------------------------------------------
> and i have used "pcolor" to draw this figure as:
> ------------------------------------------------
> h=pcolor(a);
> set(h,'LineStyle','none');
> axis image
> colorbar 
> -------------------------------------------------
> the range colorbar will be set automatically in this case (from 1 to 10).
> question is: is it possible that i can set or define this range like from 1 to 20 in this case.
> 
> thanks,
> james


Hi James,
Set the CLIM on the axes.
e.g.
a= [2.3 1.7 3.3;
    4.1 4.4 9.7;
    1.4 5.7 8.1];

h=pcolor(a);
set(h,'LineStyle','none');
axis image
colorbar 

% the color limits are a property of the axes
axHdl = get(h,'Parent'); %get the axes parent of the surface
%you will see the CLIm is set to the range of your data
cLim = get(axHdl,'CLim') %you will see the CLIm is set to the range of your data

%now set the CLIM to the range we want
set(axHdl,'CLim',[1,20])

Hope this helps
Matt W
0
Reply Matthew 10/8/2010 4:23:04 PM


1 Replies
526 Views

(page loaded in 0.04 seconds)

Similiar Articles:













7/23/2012 12:44:54 AM


Reply: