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

Home » Public Forums » archive » Scaling cgColorbar to match data
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Scaling cgColorbar to match data [message #89403] Tue, 07 October 2014 18:22 Go to previous message
Richard is currently offline  Richard
Messages: 6
Registered: June 1994
Junior Member
Hi all,

I'm attempting to generate a plot with varying symbol colours. I've been able to scale my large range of data points to a 256 colour table but I haven't got the foggiest as how to scale the cgColorbar to match. At the bottom of this post is a simple example of what I'm attempting to do.

If I've understood seeds correctly then you should be able to see what I'm seeing. In which case, I would like to direct your attention to the annotated value of 0.000278858. Notice how the coloured symbol beside it does not match that in the colour bar.

Could anybody provide any assistance or clarity in this matter?

Richard




PRO demo_color_bar

seed1=-24
seed2=57
seed3=123

x = 10 * RANDOMU(Seed1, 50)
y = 100 * RANDOMU(Seed2, 50)

z1 = 1e-1 * RANDOMU(Seed3, 10)
z2 = 1e-2 * RANDOMU(Seed3, 10)
z3 = 1e-3 * RANDOMU(Seed3, 10)
z4 = 1e-4 * RANDOMU(Seed3, 10)
z5 = 1e-5 * RANDOMU(Seed3, 10)

z = [z1,z2,z3,z4,z5]

SET_PLOT, 'PS'
DEVICE, Decomposed=0, /ENCAPSUL, /COLOR, BITS=8, FILENAME='demo_color_bar.eps', /INCHES, XSIZE=11, YSIZE=11, FONT_SIZE=10, /BOLD

!P.MULTI = [0, 1, 1]
plotPosition = [0.125, 0.06, 0.8, 0.96]

cgplot, [0, max(x)], [0, max(y)], /NODATA, /YNOZERO, title='ColorBarDemo', xtitle='x', ytitle='y', position=plotPosition

col=34 ;color table
ncol=256 ;range of colors
min_range=min(z)
max_range=max(z)

;Define scale range, converting z values into floats of 0 to 255.
Colors_test = (((ncol-1)*ALOG10(min_range))/(ALOG10(min_range)-ALOG10(max_ range)))-(((ncol-1)*ALOG10(z))/(ALOG10(min_range)-ALOG10(max _range)))

cgloadct, col, NColors=ncol

PLOTSYM, 0, /FILL

FOR i=0,49 DO BEGIN
cgplot,[x[i]],[y[i]],PSYM = 8,/OVERPLOT,color=FIX(Colors_test[i])
ENDFOR

cgloadct, 0

cgtext,x[0],y[0],z[0],/DATA,ALIGNMENT=0.0
cgtext,x[25],y[25],z[25],/DATA,ALIGNMENT=0.0
cgtext,x[49],y[49],z[49],/DATA,ALIGNMENT=0.0

cgloadct, col, NColors=ncol

cgColorbar, Divisions=24, NColors=ncol, Range=[min_range,max_range], Title='z', Format='(E11.2)', Position=[0.06, 0.82, 0.96, 0.84], /VERTICAL, /RIGHT

DEVICE, /CLOSE


END
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: cgimage - /quite keyword
Next Topic: Calculate the size of text-output

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

Current Time: Wed Oct 08 18:36:47 PDT 2025

Total time taken to generate the page: 0.00400 seconds