Re: color by variable interpolate? [message #50123] |
Tue, 12 September 2006 08:22 |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jonathan Wolfe writes:
> Thanks David for your help! That is a pretty nifty function (bytscl).
It's, uh, used pretty often. :-)
> In the end, my final code looks like this for anyone who is
> interested...
>
> LoadCT, 34, /silent ; Rainbow color table
>
> ; Scale temp from 12 to 255.
> color = BytScl( T, Top=255-12) + 12B
>
> plot,x,y,/nodata
> PLOTS, x,y , PSym=sym(3), Color=color
>
> Note that in the absence of the for loop, as David mentioned, you do
> not need to sort the array and color=color not T. :-)
I've really got to start drinking my coffee before I start
answering newsgroup queries. Ah, the perils of a home
office. :-(
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: color by variable interpolate? [message #50124 is a reply to message #50123] |
Tue, 12 September 2006 08:16  |
vorticitywolfe
Messages: 19 Registered: January 2006
|
Junior Member |
|
|
Thanks David for your help! That is a pretty nifty function (bytscl).
In the end, my final code looks like this for anyone who is
interested...
LoadCT, 34, /silent ; Rainbow color table
; Scale temp from 12 to 255.
color = BytScl( T, Top=255-12) + 12B
plot,x,y,/nodata
PLOTS, x,y , PSym=sym(3), Color=color
Note that in the absence of the for loop, as David mentioned, you do
not need to sort the array and color=color not T. :-)
David Fanning wrote:
> David Fanning writes:
>
>> I think I would do it like this:
>>
>> LoadCT, 33 ; Rainbow color table
>>
>> ; Scale temp from 12 to 255.
>> color = BytScl(T, Top=255-12) + 12B
>>
>> ; Sort temp from cold to hot
>> sortIndex = Sort(T)
>> x = x[sortIndex]
>> y = y[sortIndex]
>> T = T[sortIndex]
>> PLOT, x, y, /NoData
>> PLOTS, x, y, PSym=sym(3), Color=T
>
> Whoops! Brain jam.
>
> I was trying to use your PLOTS command, which would
> require your temperature array to be sorted, if you
> want to use it in the loop, as in your example. In my
> example, I have done away with the loop, so no sorting
> is necessary.
>
> Cheers,
>
> David
> --
> David Fanning, Ph.D.
> Fanning Software Consulting, Inc.
> Coyote's Guide to IDL Programming: http://www.dfanning.com/
> Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: color by variable interpolate? [message #50129 is a reply to message #50124] |
Tue, 12 September 2006 06:56  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
David Fanning writes:
> I think I would do it like this:
>
> LoadCT, 33 ; Rainbow color table
>
> ; Scale temp from 12 to 255.
> color = BytScl(T, Top=255-12) + 12B
>
> ; Sort temp from cold to hot
> sortIndex = Sort(T)
> x = x[sortIndex]
> y = y[sortIndex]
> T = T[sortIndex]
> PLOT, x, y, /NoData
> PLOTS, x, y, PSym=sym(3), Color=T
Whoops! Brain jam.
I was trying to use your PLOTS command, which would
require your temperature array to be sorted, if you
want to use it in the loop, as in your example. In my
example, I have done away with the loop, so no sorting
is necessary.
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|
Re: color by variable interpolate? [message #50130 is a reply to message #50129] |
Tue, 12 September 2006 06:53  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Jon writes:
> I have been trying to wrap my mind around how to make this work, but
> have not figured it out and hoped that someone could give me a little
> help.
>
> I'm trying to color some data by temperature...
>
> x y t
> 5 8 -2.5
> 6 6 -1.3
> 2 4 -5.3
> 10 6 -3.5
>
> I'm using the rainbow color table and want the warmest value -1.3 to
> correspond to the color 255 (red) and the coldest value -5.3 to
> correspond to the color 12 (dark purple)
Humm. Your way is...odd. :-)
I think I would do it like this:
LoadCT, 33 ; Rainbow color table
; Scale temp from 12 to 255.
color = BytScl(T, Top=255-12) + 12B
; Sort temp from cold to hot
sortIndex = Sort(T)
x = x[sortIndex]
y = y[sortIndex]
T = T[sortIndex]
PLOT, x, y, /NoData
PLOTS, x, y, PSym=sym(3), Color=T
> I'm not even sure if this is the best way to do
> this (a for loop).
Probably not. :-)
It might be easier to just learn how to construct a color
table that goes from red to purple in as many steps as
you want. Here is an article that describes the process:
http://www.dfanning.com/color_tips/create_colortable.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|