Hello,
After several unsuccessful attempts at trying to generate a log-scaled
colorbar using the COLORBAR function, I came up with a way to manually
create the colorbar. If someone could please look at the code and let
me know if this seems correct I would really appreciate it.
Thank you,
Kim
w = WINDOW(dimensions=[800,800],layout=[2,1,1])
; LINEAR EXAMPLE
arr = FLTARR(200,200)
for i = 0, 199 do arr(*,i) =
(0+(100/199.)*FINDGEN(200)) ; scale the array to 200
intervals ranging from 0 to 100 (adapted from the jhuapl routine
maken)
x = [MIN(arr),MAX(arr)]
im = IMAGE(arr,/
current,rgb_table=34,layout=[2,1,1],title='linear') ; display the
image
cb =
colorbar(target=im,title='idl') ; add
standard colorbar
pos =
cb.position ;
determine position for the second colorbar
pos(1) = pos(1)-.1
pos(3) = pos(3)-.1
px = 200 & py = 20
sarr =
1+(200./255.)*FINDGEN(256) ; scale
the array to 256 intervals (adapted from the jhuapl routine maken)
z = REFORM(((sarr - x(0))*FLOAT(255)/(x(1)-x(0)) + 0),
[256,1])<255 ; adapted from the jhuapl routine scalearray
xx =
FIX(0+(255./255.)*FINDGEN(px)) ;
create a scaled x array
yy =
FIX(0+(255./255.)*FINDGEN(py)) ;
create a scaled y array
bararr = INTERPOLATE(z,xx,yy,/
grid) ; interpolate to fill in the
image array
barimg = IMAGE(bararr,/
current,position=pos,rgb_table=34) ; diplay the bar image
;
overplot the tick values
p = PLOT(x,
[0,1],position=pos,xrange=x,yrange=[0,1],xticklen=0.25,min_v alue=x(0),max_value=x(1),xminor=4,yminor=0,ymajor=0,xtitle=' custom',/
nodata,/current,axis_style=1)
; LOG SCALED EXAMPLE
arr = FLTARR(200,200)
for i = 0, 199 do arr(*,i) = (-2+(4/199.)*FINDGEN(200)) ; scale the
array to 200 intervals ranging from -2 to 2 (adapted from the jhuapl
routine maken)
x = [MIN(arr),MAX(arr)]
arr = 10^(arr)
im = IMAGE(arr,/current,rgb_table=34,layout=[2,1,2],title='log')
cb = colorbar(target=im,title='idl')
pos = cb.position
pos(1) = pos(1)-.1
pos(3) = pos(3)-.1
px = 200 & py = 20
sarr = -2+(2./255.)*FINDGEN(256) ; scale the array to 256 intervals
- adapted from the jhuapl routine maken
z = REFORM(((sarr - x(0))*FLOAT(255)/(x(1)-x(0)) + 0),
[256,1])<255 ; adapted from the jhuapl routine scalearray
xx = FIX(0+(255./255.)*FINDGEN(px))
yy = FIX(0+(255./255.)*FINDGEN(py))
bararr = INTERPOLATE(z,xx,yy,/grid)
barimg = IMAGE(bararr,/current,position=pos,rgb_table=34)
p = PLOT(x,
[0,1],position=pos,xrange=x,yrange=[0,1],xticklen=0.25,min_v alue=x(0),max_value=x(1),xminor=4,yminor=0,ymajor=0,xtitle=' custom',/
nodata,/current,axis_style=1)
p.xtickname=['.01','.1','1','10','100']
|