Re: scatter plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Wed Oct 03 2012 - 01:24:46 MDT

The way I would do this is convert X and Y to 1D arrays with:

    X1d = ndtooned(X)
    Y1d = ndtooned(Y)
    nx = dimsizes(X1d)
    ny = dimsizes(Y1d) ; must be the same as nx

and then use "ind" to collect the indexes for the various ranges:

   xranges = ispan(10,100,10)
   yranges = ispan(10,100,10)
   nxr = dimsizes(xranges)
   nyr = dimsizes(yranges)

   xgroup = new((/nxr*nyr,nx/),integer)
   ygroup = new((/nxr*nyr,nx/),integer)

   igrp = 0
   do i=0,nxr-1
    do i=0,nyr-1
       ii = ind(x1d.lt.xranges(i).and.y.lt.yranges(j))
       if(.not.all(ismissing(ii))) then
          xgroup(igrp,0:dimsizes(ii)-1) = X1d(ii)
          ygroup(igrp,0:dimsizes(ii)-1) = Y1d(ii)
       end if
       delete(II)
    end do
  end do
         
You can then loop through each group and plot that group of points with the same marker color.

--Mary

   
On Sep 28, 2012, at 4:58 PM, cheryl Ma wrote:

> Thanks, Mary!
>
> In this example, data are grouped as the values of X and Y.
> I want to to firstly count the density numbers within the specific range of X and Y, e.g.
> if X < 10, Y < 10
> , 10<Y<20
> , 20<Y<30
> , 30<Y<40
> , 40<Y<50
> ...
> 40<X<50, Y < 10
> , 10<Y<20
> , 20<Y<30
> , 30<Y<40
> , 40<Y<50
>
> Suppose these density number is within (10, 100), I want to use the density to group the data, with the different color for the groups on the X-Y scatter plot, so color bar shows the density number.
>
> I can't figure out how to modify the example for this purpose, could you help me for that? thanks,
>
> Xiaoyan
>
>
>
> On Thu, Sep 27, 2012 at 12:01 PM, Mary Haley <haley@ucar.edu> wrote:
> See the attached.
>
> --Mary
>
>
> On Sep 25, 2012, at 12:48 PM, Mary Haley wrote:
>
> > Sorry, I don't think I answered the right question.
> >
> > I will try to come up with an example for you, but it may not happen for a few hours.
> >
> > --Mary
> >
> > On Sep 25, 2012, at 12:43 PM, Mary Haley wrote:
> >
> >> You could turn your 3D array (ngroups x ny x nx) into a 2D array that is dimensioned ngroups x (nx*ny) by using ndtooned/onedtond, or "reshape" (if you have V6.1.0-beta):
> >>
> >>
> >> dims3d = dimsizes(my3darray)
> >> dims2d = (/dims3d(0),dims3d(1)*dims3d(2))
> >>
> >> my2darray = onedtond(ndtooned(my3darray),dims2d)
> >>
> >> or, in V6.1.0-beta:
> >>
> >> my2darray = reshape(my3darray,dims2d)
> >>
> >>
> >> --Mary
> >>
> >> On Sep 25, 2012, at 11:17 AM, cheryl Ma wrote:
> >>
> >>> Thanks, Mary.
> >>>
> >>> This example use gsn_csm_y, using index values for the X axis. In my case I want to use the real X and Y values.
> >>> So do I need to create a 3D array (2D array in the example) to hold X, Y, and group number?
> >>>
> >>> Thanks,
> >>> Xiaoyan
> >>>
> >>> On Mon, Sep 24, 2012 at 12:34 PM, Mary Haley <haley@ucar.edu> wrote:
> >>> Hi Xiaoyan,
> >>>
> >>> See example scatter_8.ncl at:
> >>>
> >>> http://www.ncl.ucar.edu/Applications/scatter.shtml
> >>>
> >>> --Mary
> >>>
> >>> On Sep 24, 2012, at 8:55 AM, cheryl Ma wrote:
> >>>
> >>>> Hi all,
> >>>>
> >>>> I want to make a scatter plot, with color coded as a function of density (looks like the plot attached below).
> >>>> Generally I use gsn_csm_xy to make scatter plot. Does anyone know how to make a scatterplot as shown?
> >>>>
> >>>> Thanks in advance,
> >>>> Xiaoyan
> >>>>
> >>>> <image.png>
> >>>> _______________________________________________
> >>>> ncl-talk mailing list
> >>>> List instructions, subscriber options, unsubscribe:
> >>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >>>
> >>>
> >>
> >> _______________________________________________
> >> ncl-talk mailing list
> >> List instructions, subscriber options, unsubscribe:
> >> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> >
> > _______________________________________________
> > ncl-talk mailing list
> > List instructions, subscriber options, unsubscribe:
> > http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Wed Oct 3 01:25:00 2012

This archive was generated by hypermail 2.1.8 : Mon Oct 08 2012 - 15:54:16 MDT