Problems with colorbar matching contour colors [message #85466] |
Sun, 11 August 2013 15:23  |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
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. 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. Thank you.
nlevels=26
loadct, 41, ncolors=26
cgDisplay, 600, 500
contourlevels = cgConLevels(EpBin, nlevels=25, MaxValue=25)
cgplot, lonrange, latrange, /noerase, xstyle=1,ystyle=1,/nodata,xrange=xrange,$
yrange=yrange, position=pp, yticks = 8, xticks=6, xminor=1, charsize=1, $
xtitle = 'Longitude', ytitle = 'Latitude'
cgcontour, EpBin, longrid, latgrid, levels=contourlevels, /fill, $
c_colors=indgen(nlevels)+1, /overplot, position=[0.125,0.125,0.8,0.85]
cgcolorbar;, range=[0,25], divisions=5, position=[0.125, 0.92, 0.9, 0.96],/vertical,/right
|
|
|
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.")
|
|
|