Re: help with scatter plot with 3 variables

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Fri, 18 Aug 2006 10:41:42 -0600 (MDT)

Hi Rahul,

There's no way to have colors and marker sizes automatically selected
for things like polymarkers (you can do this for contours and vector
colors).

The way to do this for polymarkers is to group the data values that
you want to be one particular color and size, set the desired color
and size marker for that group, and then draw that set of markers.
Repeat this for all groups of markers.

There's an example that does what I think you want, although it is not
swath data. Please see example 8 at:

    http://www.ncl.ucar.edu/Applications/polyg.shtml

Note that this is just dummy data, and the data is grouped according
to a given set of values. That is, the data values go from -1.2 to
35, and the groupings are done for values < 0, values between 0 and 5,
values been 5 and 10, and so on up to values over 26.

You can do something similar, except in your case it sounds like
the groupings will be at even intervals, so you can modify the
code as necessary. Instead of :

  arr = (/0.,5.,10.,15.,20.,23.,26./)

you might have something like:

   ngroups = 10 ; Number of distinct colors and sizes you want
   arr = fspan(min(C),max(C),ngroups)

You can then use the values in "arr" to group your markers as they are
being done in this example.

--Mary

On Thu, 17 Aug 2006, Rahul Kanwar wrote:

> Hello Adam,
> Thank you for your reply. I have brightness temperature data from
> SMMR which has (lat, lon , Tb) pairs and i want to plot it over a map. I
> do not want to interpolate it as its swath data and does not cover the
> whole globe, i want to put circles at lat, lon with colors corresponding
> to Tb.
> Your code seems to work. Is there some way to assign the color values
> for z automatically. I wanted something like this (its from matlab) :
>
> scatter(X,Y,S,C)
>
> where S is the size of the marker and C is the z values, matlab
> automatically scales the data according to the colormap being used.
>
> bye,
> Rahul
>
> On Thu, 2006-08-17 at 17:07 -0600, Adam Phillips wrote:
>> Hi Rahul,
>>
>> I am not so sure that you want a true scatter plot. Assuming you have
>> monotonically increasing X-axis values, you can use gsn_csm_xy to plot
>> the markers, and then use the resource xyMarkerColors to set the markers
>> colors based on Z. For example:
>>
>> wks = gsn_open_wks("ps","test")
>> gsn_define_colormap(wks,"wh-bl-gr-ye-re")
>> res = True
>> .........
>> colors = new(dimsizes(Z),"string")
>>
>> do gg = 0,dimsizes(Z)-1
>> if (Z(gg).lt..2) then
>> colors(gg) = "red"
>> end if
>> if (Z(gg).ge..2.and.Z(gg).lt..3) then
>> colors(gg) = "orange"
>> end if
>>
>> ; and so on
>>
>> end do
>> res_at_xyMarkerColor = colors
>> plot = gsn_csm_xy(wks,X,Y,res)
>> end
>>
>> Good luck...
>> Adam
>>
>>
>> Rahul Kanwar wrote:
>>> Hello,
>>>
>>> I want to make a scatter plot with the data following type of data:
>>>
>>> X Y Z
>>> 1 2 3
>>> 2 3 4
>>> 3 5 5
>>> 4 3 7
>>>
>>> The values in the Z column are in decimals and vary from 0-300. I
>>> want to make a scatter plot with x-y axis and have circle 'o' as the
>>> marker with color of the marker varying according to the Z axis (I do'nt
>>> want to grid the data).
>>> I have tried suing xy but it dose'nt seem to be working. Can some one
>>> please help me with it ?
>>>
>>> regards,
>>> Rahul
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk_at_ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk_at_ucar.edu
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 18 2006 - 10:41:42 MDT

This archive was generated by hypermail 2.2.0 : Fri Aug 18 2006 - 10:43:09 MDT