Re: Problems with colorbar matching contour colors [message #85467 is a reply to message #85466] |
Sun, 11 August 2013 18:10  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Morgan Silverman writes:
> I've created a new colortable. When I load the colortable to only
> use 26 colors to match the 25 contour levels I've plotted,
> the colorbar displays the colors squished at the bottom and
> then a gray scale colorbar for the remaining space. I'm not
> sure why this is happening.
Well, you don't indicate to the color bar that you are using a
restricted number of colors. That is the purpose of the NCOLORS keyword.
In the absence of information, it uses all 256 colors.
> I only want my color bar to go
> from 0-25 even though my max value is well above 100. I
> want the values higher than 25 to be the same color as
> the 25th. An abbreviated code is below. I'd appreciate
> any help with why the colorbar isn't filling with the
> abbreviated number of colors or a better way to do this.
I think you want something like this:
loadct, 0
loadct, 41, ncolors=26
data = dist(50)
contourLevels = [Indgen(26), Max(data)]
cgDisplay, 800, 700
cgcontour, data, Levels=contourLevels, /fill, $
position=[0.125,0.125,0.8,0.85], $
c_colors=indgen(26), /label, /outline
cgcolorbar, ncolors=25, range=[0,25], oob_high=25B, ticklen=1.0, $
divisions=25, position=[0.125, 0.9, 0.9, 0.93],/vertical,/right
END
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.idlcoyote.com/
Sepore ma de ni thue. ("Perhaps thou speakest truth.")
|
|
|