scatter plot , intensity colors. Help [message #86511] |
Fri, 15 November 2013 05:06  |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
Dear all,
I need to do a scatterplot with colored symbols representing the intensity. I am adapting an example I found at http://www.idlcoyote.com/gallery/colored_line_plot.pro I am doing the following:
X=[2, 4, 5, 6, 7, 8]
Y=[20, 40, 45, 30, 10, 5]
I=[100,200,300,400,500,600]
;intensity color
colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
clr = Value_Locate(colors, I)
clr = Byte(Round(cgScaleVector(clr, 0, 255)))
cgLoadCT, 33
cgWindow
;the scatterplot
cgPlot, X, Y, /Nodata, /AddCMD
FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
Color=clr[j], Psym=16,symsize=2,/AddCMD
FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
Color=clr[j], Psym=16,symsize=2, /AddCMD
However the output produces a gray scale image.
1. What am I doing wrong?
2. How can I add a color bar associated with the intensity (I)?
I will appreciate any assistance.
Cheers,
Lim
|
|
|
Re: scatter plot , intensity colors. Help [message #86515 is a reply to message #86511] |
Fri, 15 November 2013 06:25   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lim writes:
>
> Dear all,
>
> I need to do a scatterplot with colored symbols representing the intensity. I am adapting an example I found at http://www.idlcoyote.com/gallery/colored_line_plot.pro I am doing the following:
>
> X=[2, 4, 5, 6, 7, 8]
> Y=[20, 40, 45, 30, 10, 5]
> I=[100,200,300,400,500,600]
>
> ;intensity color
> colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
> clr = Value_Locate(colors, I)
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
> cgLoadCT, 33
> cgWindow
>
> ;the scatterplot
> cgPlot, X, Y, /Nodata, /AddCMD
> FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
> Color=clr[j], Psym=16,symsize=2,/AddCMD
> FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
> Color=clr[j], Psym=16,symsize=2, /AddCMD
>
>
> However the output produces a gray scale image.
> 1. What am I doing wrong?
My guess would be using an outdated Coyote Library. There is no gray
scale coloring when I run your example. I follow these steps to resolve
these kinds of issues:
http://www.idlcoyote.com/code_tips/fixcoyoteprogram.php
> 2. How can I add a color bar associated with the intensity (I)?
I think I would use cgColorbar. Did this *not* work for some reason?
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: scatter plot , intensity colors. Help [message #86523 is a reply to message #86511] |
Fri, 15 November 2013 08:37   |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
On Friday, November 15, 2013 8:06:17 AM UTC-5, Lim wrote:
> Dear all,
>
>
>
> I need to do a scatterplot with colored symbols representing the intensity. I am adapting an example I found at http://www.idlcoyote.com/gallery/colored_line_plot.pro I am doing the following:
>
>
>
> X=[2, 4, 5, 6, 7, 8]
>
> Y=[20, 40, 45, 30, 10, 5]
>
> I=[100,200,300,400,500,600]
>
>
>
> ;intensity color
>
> colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
>
> clr = Value_Locate(colors, I)
>
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
>
>
> cgLoadCT, 33
>
> cgWindow
>
>
>
> ;the scatterplot
>
> cgPlot, X, Y, /Nodata, /AddCMD
>
> FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
>
> Color=clr[j], Psym=16,symsize=2,/AddCMD
>
> FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
>
> Color=clr[j], Psym=16,symsize=2, /AddCMD
>
>
>
>
>
> However the output produces a gray scale image.
>
> 1. What am I doing wrong?
>
> 2. How can I add a color bar associated with the intensity (I)?
>
>
>
> I will appreciate any assistance.
>
>
>
> Cheers,
>
>
>
> Lim
Hi David,
1. Colors: I have updated my coyote library. Now I can see the colors. Thanks.
2. Colorbar: To be honest I do not have a clear idea about how to include the color bar with the colors matching those I used in the intensity. I will appreciate any suggestions.
Thanks,
Lim
|
|
|
Re: scatter plot , intensity colors. Help [message #86524 is a reply to message #86511] |
Fri, 15 November 2013 08:46   |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
On Friday, November 15, 2013 8:06:17 AM UTC-5, Lim wrote:
> Dear all,
>
>
>
> I need to do a scatterplot with colored symbols representing the intensity. I am adapting an example I found at http://www.idlcoyote.com/gallery/colored_line_plot.pro I am doing the following:
>
>
>
> X=[2, 4, 5, 6, 7, 8]
>
> Y=[20, 40, 45, 30, 10, 5]
>
> I=[100,200,300,400,500,600]
>
>
>
> ;intensity color
>
> colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
>
> clr = Value_Locate(colors, I)
>
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
>
>
> cgLoadCT, 33
>
> cgWindow
>
>
>
> ;the scatterplot
>
> cgPlot, X, Y, /Nodata, /AddCMD
>
> FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
>
> Color=clr[j], Psym=16,symsize=2,/AddCMD
>
> FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
>
> Color=clr[j], Psym=16,symsize=2, /AddCMD
>
>
>
>
>
> However the output produces a gray scale image.
>
> 1. What am I doing wrong?
>
> 2. How can I add a color bar associated with the intensity (I)?
>
>
>
> I will appreciate any assistance.
>
>
>
> Cheers,
>
>
>
> Lim
Hi David,
I just saw you the solution to my problem:
http://www.idlcoyote.com/color_tips/colorbar.html
Thank you very much
Lim
|
|
|
Re: scatter plot , intensity colors. Help [message #86527 is a reply to message #86523] |
Fri, 15 November 2013 08:54   |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lim writes:
> 1. Colors: I have updated my coyote library. Now I can see the colors. Thanks.
>
> 2. Colorbar: To be honest I do not have a clear idea about how to include the color bar with the colors matching those I used in the intensity. I will appreciate any suggestions.
I would probably do it like this:
;----------------------------------------------------------- ---
X=[2, 4, 5, 6, 7, 8]
Y=[20, 40, 45, 30, 10, 5]
I=[100,200,300,400,500,600]
;intensity color
colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
clr = Value_Locate(colors, I)
clr = Byte(Round(cgScaleVector(clr, 0, 255)))
TVLCT, r, g, b, /Get
TVLCT, r[clr], g[clr], b[clr], 1
TVLCT, r, g, b, /Get
cgWindow, 'TVLCT', r, g, b
;the scatterplot
cgPlot, X, Y, /Nodata, /AddCMD, Position=[0.125, 0.125, 0.9, 0.8]
FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
Color=clr[j+1], Psym=16,symsize=2,/AddCMD
FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
Color=clr[j+1], Psym=16,symsize=2, /AddCMD
cgDCBar, NColors=N_Elements(clr), Bottom=1, /AddCmd
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: scatter plot , intensity colors. Help [message #86534 is a reply to message #86511] |
Sun, 17 November 2013 02:59   |
limiqt
Messages: 27 Registered: October 2013
|
Junior Member |
|
|
My final code:
Pro sctrpInt
X=[2, 4, 5, 6, 7, 8]
Y=[20, 40, 45, 30, 10, 5]
I=[100,200,300,400,500,600]
nelm=n_elements(X)
colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
clr = Value_Locate(colors, I)
clr = Byte(Round(cgScaleVector(clr, 0, 255)))
cgLoadCT, 33
cgWindow
;the scatterplot
cgPlot, X, Y, /Nodata, /AddCMD
FOR j=0,nelms-1 DO cgPlotS, X[j], Y[j],Color=clr[j], Psym=16,symsize=2,/AddCMD
cgColorbar, Divisions=5, Format='(I3)', Range=[100,600], /AddCMD , Title='I'
End
On Friday, November 15, 2013 8:06:17 AM UTC-5, Lim wrote:
> Dear all,
>
>
>
> I need to do a scatterplot with colored symbols representing the intensity. I am adapting an example I found at http://www.idlcoyote.com/gallery/colored_line_plot.pro I am doing the following:
>
>
>
> X=[2, 4, 5, 6, 7, 8]
>
> Y=[20, 40, 45, 30, 10, 5]
>
> I=[100,200,300,400,500,600]
>
>
>
> ;intensity color
>
> colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
>
> clr = Value_Locate(colors, I)
>
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
>
>
> cgLoadCT, 33
>
> cgWindow
>
>
>
> ;the scatterplot
>
> cgPlot, X, Y, /Nodata, /AddCMD
>
> FOR j=0,N_Elements(X)-2 DO cgPlotS, [X[j], X[j+1]], [Y[j], Y[j+1]], $
>
> Color=clr[j], Psym=16,symsize=2,/AddCMD
>
> FOR j=0,N_Elements(pNPP)-1,2 DO cgPlotS, X[j], Y[j], $
>
> Color=clr[j], Psym=16,symsize=2, /AddCMD
>
>
>
>
>
> However the output produces a gray scale image.
>
> 1. What am I doing wrong?
>
> 2. How can I add a color bar associated with the intensity (I)?
>
>
>
> I will appreciate any assistance.
>
>
>
> Cheers,
>
>
>
> Lim
|
|
|
Re: scatter plot , intensity colors. Help [message #86536 is a reply to message #86534] |
Sun, 17 November 2013 07:38  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Lim writes:
> My final code:
>
> Pro sctrpInt
>
> X=[2, 4, 5, 6, 7, 8]
> Y=[20, 40, 45, 30, 10, 5]
> I=[100,200,300,400,500,600]
> nelm=n_elements(X)
> colors = cgScaleVector(Findgen(N_Elements(I)), Min(I), Max(I))
> clr = Value_Locate(colors, I)
> clr = Byte(Round(cgScaleVector(clr, 0, 255)))
>
> cgLoadCT, 33
> cgWindow
> ;the scatterplot
> cgPlot, X, Y, /Nodata, /AddCMD
> FOR j=0,nelms-1 DO cgPlotS, X[j], Y[j],Color=clr[j], Psym=16,symsize=2,/AddCMD
> cgColorbar, Divisions=5, Format='(I3)', Range=[100,600], /AddCMD , Title='I'
>
> End
I prefer to have the color bar separate from the plot and not
overwritten on top of it, but aesthetics are completely up to you. ;-)
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.")
|
|
|