Re: Color data points by 3rd variable [message #84084 is a reply to message #84082] |
Thu, 25 April 2013 07:37   |
morganlsilverman
Messages: 46 Registered: February 2013
|
Member |
|
|
On Thursday, April 25, 2013 10:15:49 AM UTC-4, David Fanning wrote:
> Morgan Silverman writes:
>
>
>
>> I'm plotting the latitude and longitude locations of the top 5% of my dataset. I want to color the locations of these data points by corresponding no2 values. I'm having a hard time figuring out how to set up the colorscale and colorbar correctly. I tried something along the lines of
>
>>
>
>> no2temp = no2sorted(0:83) ; only want top 5% of data points (83 values out of 1661)
>
>> NO2colors = no2temp
>
>> NO2colors(*) = 0
>
>> NO2colors = fix(no2temp*255/(max(no2temp)-min(no2temp)))
>
>> cgcolors = cgColor(Bindgen(256))
>
>> NO2colors = cgcolors[NO2colors]
>
>>
>
>> but it doesn't seem to work quite right. I'd like the range to be [1e16, 4e16]. Looking for any insight. Thanks.
>
>
>
> It isn't clear to me if you are plotting *all* the data, but only the
>
> top five percent is colored, of if you just want to plot the top five
>
> percent and you want the data colored. If you want the latter, and
>
> assuming your variables are lon, lat, and temps, I would do it like
>
> this:
>
>
>
> cutoff95 = Max(temps) * 0.95
>
> indices = Where(temps GE cutoff95)
>
> lon5 = lon[indices]
>
> lat5 = lat[indices]
>
> temp5 = temps[indices]
>
> colors = BytScl(temp5)
>
> cgPlotS, lon5, lat5, Color=colors
>
>
>
> I may have the cutoff wrong. I'm really not clear what the "top 5% of my
>
> dataset" means. :-)
>
>
>
> 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.")
David,
Thanks for responding. To clarify, it is the latter. I want to plot only the outliers of high values in my dataset and color those. I tried to sort the data and select only the values that were within the highest 5% of all values. I'm not sure I calculated that correctly either.
-Morgan
|
|
|