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

Home » Public Forums » archive » Multiple color plots, same color bar
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
Multiple color plots, same color bar [message #86827] Thu, 05 December 2013 14:22 Go to next message
limiqt is currently offline  limiqt
Messages: 27
Registered: October 2013
Junior Member
Dear all,
I was wondering if someone could help me with a problem using one color bar for multiple plots with different ranges of colors. My example bellow produces two panels and one color bar. However the color bar does not match both panels but only the first one (I1 values).
For I1 and I2, I need to do:
100-200=red
201-300=orange
301-400=yellow
401-500=green
501-600=blue

therefore, using a color table from 0 to 600, the second panel should not have any blue color.

I will appreciate any assistance.

Thanks,
Lim
==============
pro mci

X1=[2, 4, 5, 6, 7, 8]
Y1=[20, 40, 45, 30, 10, 5]
I1=[100,200,300,400,500,600]

X2=[3, 4.5, 5.5, 6.5, 7.5, 8.5]
Y2=[22, 25, 30, 33, 20, 8]
I2=[150,175,250,280,290,450]

cgLoadCT, 33, /reverse
nelmspix=n_elements(X1)
colors = cgScaleVector(Findgen(N_Elements(I1)), min(I1), max(I1))
clr = Value_Locate(colors, I1)
clr = Byte(Round(cgScaleVector(clr, 0, 255)))

cgWindow
pos1=[0.1,0.1,0.45,0.75]
pos2=[0.55,0.1,0.9,0.75]
;graph 1
cgPlot, X1, Y1, /Nodata, Xtitle='X', Ytitle='Y', position=pos1,/NoErase,/AddCMD
cgPlotS, X1, Y1, Psym=16,symsize=2,color=clr,/AddCMD
;graph 2
cgplot,X2,Y2, /Nodata, Xtitle='X', Ytitle='Y', position=pos2,/NoErase, /AddCMD
cgPlotS, X2, Y2,Psym=16,symsize=2,color=clr,/AddCMD
;the colorbar
cgColorbar, Divisions=5, Format='(I3)', Range=[100,600],/AddCMD , TLOCATION='Top', Title='I'

End
==============
Re: Multiple color plots, same color bar [message #86828 is a reply to message #86827] Thu, 05 December 2013 14:57 Go to previous messageGo to next message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lim writes:

>
> Dear all,
> I was wondering if someone could help me with a problem using one color bar for multiple plots with different ranges of colors. My example bellow produces two panels and one color bar. However the color bar does not match both panels but only the first one (I1 values).
> For I1 and I2, I need to do:
> 100-200=red
> 201-300=orange
> 301-400=yellow
> 401-500=green
> 501-600=blue
>
> therefore, using a color table from 0 to 600, the second panel should not have any blue color.
>
> I will appreciate any assistance.

You want this:

pro mci

X1=[2, 4, 5, 6, 7, 8]
Y1=[20, 40, 45, 30, 10, 5]
I1=[100,200,300,400,500,600]

X2=[3, 4.5, 5.5, 6.5, 7.5, 8.5]
Y2=[22, 25, 30, 33, 20, 8]
I2=[150,175,250,280,290,450]

cgLoadCT, 33, /reverse
clr1 = BytScl(i1, MIN=100, MAX=600)
clr2 = BytScl(i2, MIN=100, MAX=600)

cgWindow
pos1=[0.1,0.1,0.45,0.75]
pos2=[0.55,0.1,0.9,0.75]
;graph 1
cgPlot, X1, Y1, /Nodata, Xtitle='X', Ytitle='Y', $
position=pos1,/NoErase,/AddCMD
cgPlotS, X1, Y1, Psym=16,symsize=2,color=clr1,/AddCMD
;graph 2
cgplot,X2,Y2, /Nodata, Xtitle='X', Ytitle='Y', $
position=pos2,/NoErase, /AddCMD
cgPlotS, X2, Y2,Psym=16,symsize=2,color=clr2,/AddCMD
;the colorbar
cgColorbar, Divisions=5, Format='(I3)', Range=[100,600],$
/AddCMD , TLOCATION='Top', Title='I'

End

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: Multiple color plots, same color bar [message #86829 is a reply to message #86827] Thu, 05 December 2013 15:47 Go to previous messageGo to next message
limiqt is currently offline  limiqt
Messages: 27
Registered: October 2013
Junior Member
Hi David,
Yes, Your solution worked. Need to read about the bytscl. Thanks you very much.

Lim

On Thursday, December 5, 2013 5:22:48 PM UTC-5, Lim wrote:
> Dear all,
>
> I was wondering if someone could help me with a problem using one color bar for multiple plots with different ranges of colors. My example bellow produces two panels and one color bar. However the color bar does not match both panels but only the first one (I1 values).
>
> For I1 and I2, I need to do:
>
> 100-200=red
>
> 201-300=orange
>
> 301-400=yellow
>
> 401-500=green
>
> 501-600=blue
>
>
>
> therefore, using a color table from 0 to 600, the second panel should not have any blue color.
>
>
>
> I will appreciate any assistance.
>
>
>
> Thanks,
>
> Lim
>
> ==============
>
> pro mci
>
>
>
> X1=[2, 4, 5, 6, 7, 8]
>
> Y1=[20, 40, 45, 30, 10, 5]
>
> I1=[100,200,300,400,500,600]
>
>
>
> X2=[3, 4.5, 5.5, 6.5, 7.5, 8.5]
>
> Y2=[22, 25, 30, 33, 20, 8]
>
> I2=[150,175,250,280,290,450]
>
>
>
> cgLoadCT, 33, /reverse
>
> nelmspix=n_elements(X1)
>
> colors = cgScaleVector(Findgen(N_Elements(I1)), min(I1), max(I1))
>
> clr = Value_Locate(colors, I1)
>
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
>
>
> cgWindow
>
> pos1=[0.1,0.1,0.45,0.75]
>
> pos2=[0.55,0.1,0.9,0.75]
>
> ;graph 1
>
> cgPlot, X1, Y1, /Nodata, Xtitle='X', Ytitle='Y', position=pos1,/NoErase,/AddCMD
>
> cgPlotS, X1, Y1, Psym=16,symsize=2,color=clr,/AddCMD
>
> ;graph 2
>
> cgplot,X2,Y2, /Nodata, Xtitle='X', Ytitle='Y', position=pos2,/NoErase, /AddCMD
>
> cgPlotS, X2, Y2,Psym=16,symsize=2,color=clr,/AddCMD
>
> ;the colorbar
>
> cgColorbar, Divisions=5, Format='(I3)', Range=[100,600],/AddCMD , TLOCATION='Top', Title='I'
>
>
>
> End
>
> ==============
Re: Multiple color plots, same color bar [message #86830 is a reply to message #86829] Thu, 05 December 2013 15:52 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
Lim writes:

> Yes, Your solution worked. Need to read about the bytscl

Yes, essential for working with color tables of all sorts. ;-)

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.")
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: structure references
Next Topic: How to close all of figures at the same time using IDL command?

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

Current Time: Wed Oct 08 13:40:44 PDT 2025

Total time taken to generate the page: 0.00449 seconds