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 
Switch to threaded view of this topic Create a new topic Submit Reply
Scaling cgColorbar to match data [message #89403] Tue, 07 October 2014 18:22 Go to next 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
Re: Scaling cgColorbar to match data [message #89407 is a reply to message #89403] Wed, 08 October 2014 20:40 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Richard writes:

> 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.

I'm not sure I'm seeing what you are seeing, but I would change this
code:

> 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

To this:

cgloadct, col, NColors=ncol
FOR i=0,49 DO BEGIN
cgplot,[x[i]],[y[i]],PSYM = 16,/OVERPLOT,color=BYTE(Colors_test[i])
ENDFOR

Does that make any difference?

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.")
Re: Scaling cgColorbar to match data [message #89409 is a reply to message #89407] Thu, 09 October 2014 07:10 Go to previous message
Richard is currently offline  Richard
Messages: 6
Registered: June 1994
Junior Member
Hi David,
Many thanks for the response.
I'm not seeing any visual difference between my method or yours but I believe that I have resolved my issue by coming back to the problem with fresh eyes and simply restarting my IDL environment.

Cheers,
Richard

P.S. Thanks for all the great IDL code and support you provide. It has saved myself and colleagues from countless headaches as well as preventing us from cowering under our desks muttering evil curses at IDL!
  Switch to threaded view of this topic Create a new topic Submit Reply
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 13:31:05 PDT 2025

Total time taken to generate the page: 0.00593 seconds