colorbar [message #88410] |
Wed, 23 April 2014 05:53  |
shbhuk
Messages: 1 Registered: April 2014
|
Junior Member |
|
|
I am trying to add a colorbar to the image generated by tvim and following is the code I am using.
---
loadct,4,ncolors=100
grid=bytscl(grid,0,1000)
tvim,grid
colorbar,ncolors=100
Though I get a colorbar on the image, the colorbar is empty and does not have the colorgradient.
On using cgcolorbar and tvim for the same, the colorbar obtained does not match with the color values in the image.
|
|
|
Re: colorbar [message #88411 is a reply to message #88410] |
Wed, 23 April 2014 06:52  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
shbhuk@gmail.com writes:
> On using cgcolorbar and tvim for the same, the colorbar obtained does not match with the color values in the image.
Yes, because you scale your image into 255 values, but use only 100
colors in your color bar. If you want to match your image, the values in
the image have to match the colors in the color bar.
cgloadct, 4, ncolors=100
grid = cgDemodata(18)
grid = bytscl(grid, Top=99, Min=0, Max=100)
cgImage, grid, Position=[0.125, 0.1, 0.925, 0.8], /Axes
cgColorbar, ncolors=100, range=[0, 100]
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.")
|
|
|