comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Log-scaled colorbar example
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Log-scaled colorbar example [message #76220 is a reply to message #76217] Tue, 24 May 2011 07:56 Go to previous messageGo to previous message
Kim is currently offline  Kim
Messages: 19
Registered: January 2009
Junior Member
> Can you reproduce this figure and color bar with your
> code? (I haven't been able to, but I've spent less than
> an hour trying.) When you can reproduce this figure, then
> I think you are on the right track.


> Cheers,


> David



I think I was able to reproduce your colorbar and generate a similar
graphic as the example I provided above. I did find an error in the
original code with the tickmarks and added /xlog to the plot command.
I would appreciate you opinion on the following example.
Thank you for your assistance,
Kim

; Read image
image = cgDemoData(7) ; World Elevation Data
image = Scale_Vector(image, 1, 2500L)
logImage = Alog10(image)
X = FLOAT([MIN(IMAGE),MAX(IMAGE)])
XLOG = [MIN(LOGIMAGE),MAX(LOGIMAGE)]


; Create the color bar image
PX = 200 & PY = 20
RGB_TABLE=33
COLOR_RANGE = [0.0,255.0]
NCOLORS = COLOR_RANGE(1) - COLOR_RANGE(0) + 1
SARR = X(0)+((X(1)-X(0))/
256)*FINDGEN(256) ; scale the array to 256
intervals (adapted from the jhuapl routine maken)
Z = REFORM(((SARR - X(0))*FLOAT(COLOR_RANGE(1)-COLOR_RANGE(0))/(X(1)-
X(0)) + COLOR_RANGE(0)),[256,1])<255 ; adapted from the jhuapl
routine scalearray
XX = FIX(COLOR_RANGE(0)+((COLOR_RANGE(1)-COLOR_RANGE(0))/
(NCOLORS-1))*FINDGEN(PX)) ; create a scaled x
array
YY = FIX(COLOR_RANGE(0)+((COLOR_RANGE(1)-COLOR_RANGE(0))/
(NCOLORS-1))*FINDGEN(PY)) ; create a scaled y
array
BARARR = INTERPOLATE(Z,XX,YY,/
GRID) ; interpolate to fill in the
image array

; Linear example
W = WINDOW(DIMENSIONS=[800,800],LAYOUT=[2,1,1])
IMG = IMAGE(IMAGE,RGB_TABLE=RGB_TABLE,/
CURRENT,LAYOUT=[2,1,1],TITLE='Linear')
CB = COLORBAR(TARGET=IMG,TITLE='IDL')
POS =
CB.POSITION ;
determine position for the second colorbar
POS(1) = pos(1)-.1
POS(3) = POS(3)-.1
BARIMG = IMAGE(BARARR,/
CURRENT,POSITION=POS,RGB_TABLE=RGB_TABLE) ; diplay the bar image
then 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_V­
ALUE=X(1),XMINOR=4,YMINOR=0,YMAJOR=0,XTITLE='CUSTOM',/NODATA ,/
CURRENT,AXIS_STYLE=1)


; Log example
IMG2 = IMAGE(LOGIMAGE,RGB_TABLE=RGB_TABLE,/
CURRENT,LAYOUT=[2,1,2],TITLE='Log Scales')
CB = COLORBAR(TARGET=IMG2,TITLE='IDL')
POS = CB.POSITION
POS(1) = pos(1)-.1
POS(3) = POS(3)-.1
BARIMG = IMAGE(BARARR,/CURRENT,POSITION=POS,RGB_TABLE=RGB_TABLE)
P = PLOT(XLOG,[0,1],/
XLOG,POSITION=POS,XRANGE=X,YRANGE=[0,1],XTICKLEN=0.25,MIN_VA LUE=X(0),MAX_VA­
LUE=(1),XMINOR=4,YMINOR=0,YMAJOR=0,XTITLE='CUSTOM',/NODATA,/
CURRENT,AXIS_STYLE=1)
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Displaying thicker lines on an image
Next Topic: Re: IDL for dummies

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 00:52:14 PDT 2025

Total time taken to generate the page: 0.63808 seconds