Re: a question regarding scatter plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Apr 04 2011 - 08:24:59 MDT

On Apr 1, 2011, at 10:26 AM, H.Dang wrote:

> Hi Mary,
>
> Thanks for your kind explanation. So my current understanding is that "gsn_csm_xy (wks,ts&time,data,res)" is to plot 2 sets of data. :
>
> 1. ts vs. data(0,:)
> 2. ts vs. data(1,:)

It's more like:

  data(0,:) vs ts&time
  data(1,:) vs ts&time

"data" is for the Y axis, and ts&time is the X axis. It's not plotting "ts", but the time coordinates associated with "ts".

What you are seeing in this figure is correct. If you were to print the ts&time values, you would see they go from 6113 to 9125, and this is what you see on the X axis.

The data(0,:) values go from 268.0111 to 271.0618, and the data(1,:) values (the line) go from 268.4577 to 270.5234.

The "x" array was simply used as input to "regline", which caculates the regression coefficient.

--Mary

>
> Based on http://www.ncl.ucar.edu/Applications/Scripts/scatter_4.ncl,
>
> x = ispan(0,dimsizes(ts)-1,1)*1.
> ...
> data(0,:) = ts
> data(1,:) = rc*(x-rc@xave) + rc@yave
> ...
> res@xyMarkLineModes = (/"Markers","Lines"/) ; choose which have markers
> ...
> plot = gsn_csm_xy (wks,ts&time,data,res) ; create plot
> end
>
> It firtly plots "ts vs data(0,:)=ts", which should be a line with slope 1. Then it will plot "ts vs data(1,:)=regression line". In both cases, ts is the x-axes, but this code corresponds to the figure http://www.ncl.ucar.edu/Applications/Images/scatter_4_lg.png
>
> Since this figure's x-axes is "time", I don't understand why the code is not like:
>
> plot = gsn_csm_xy (wks,x,data,res)
>
>
> Cheers
> Hongyan
> On Fri, Apr 1, 2011 at 10:13 AM, Mary Haley <haley@ucar.edu> wrote:
> On Mar 31, 2011, at 5:06 PM, H.Dang wrote:
>
>> Hi dear all,
>>
>> I have a question regarding a scatter plot example on NCL website:
>>
>> http://www.ncl.ucar.edu/Applications/Scripts/scatter_4.ncl
>>
>> The last 2 lines are:
>>
>> plot = gsn_csm_xy (wks,ts&time,data,res) ; create plot
>> end
>>
>> The "&time" doesn't work in my NCL, but I can get plots simply use:
>>
>> plot = gsn_csm_xy (wks,ts,data,res) ; create plot
>> end
>>
>> I'm not sure if it's okay if I do it this way.
>
> Dear Hongyan,
>
> It's okay to put "ts" there, as long as the dimensions of ts and data are correct, and that this is what you actually want to plot.
> This call will simply put the "ts" values on your X axis and the "data" values on your Y axis.
>
>
>> And is the x-axes is the pre-defined "x"?
>>
>> x = ispan(0,dimsizes(ts)-1,1)*1.
>
>
> No, it should be set to the values of "ts". That is, the X values will span min(ts) to max(ts).
>
> If you had used:
>
> plot = gsn_csm_y(wks,data,res) ; Note, no "ts"
>
> Then "data" would be on your Y axis, and the x axis would be the "ispan" values as you defined above.
>
> --Mary
>
>>
>> Thank you.
>> --
>> Cordially,
>> Hongyan(ΊθΡγ)
>> Tel: 1-519-8884567ext36667
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
> --
> Cordially,
> Hongyan(ΊθΡγ)
> Tel: 1-519-8884567ext36667
>
>
> _______________________________________________
> 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 Mon Apr 4 08:24:59 2011

This archive was generated by hypermail 2.1.8 : Tue Apr 05 2011 - 09:01:21 MDT