Re: About multi-line XY plot

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon, 9 Apr 2007 08:59:28 -0600 (MDT)

Hi Lawrence,

It looks like you've already received several suggestions here, and
I'll offer another one. You can try putting all your datasets into one
big 2D array, and then plot this with a single call to gsn_csm_xy.

For example, if you have 5 sets of model data, each with a different
number of X,Y values, then you can set up a 5 x N array, where N
is the length of the dataset with the most values.

For example, assume you have datasets (x1,y1), (x2,y2), (x3,y3),
(x4,y4), and (x5,y5) of lengths N1, N2, N3, N4, and N5 respectively.

To gather these into one big array (I'm assuming they are all the
same type):

   N = max((/N1,N2,N3,N4,N5/)) ; Get length of largest dataset.
   x = new((/5,N/),typeof(x1)) ; Create new 2D arrays to hold all data
   y = new((/5,N/),typeof(y1)) ; values. Rest of values will be missing.

   x(0,0:N1-1) = x1
   y(0,0:N1-1) = y1
   x(1,0:N2-1) = x2
   y(1,0:N2-1) = y2
   x(2,0:N3-1) = x3
   y(2,0:N3-1) = y3
   x(3,0:N4-1) = x4
   y(3,0:N4-1) = y4
   x(4,0:N5-1) = x5
   y(4,0:N5-1) = y5

   ...
   xy = gsn_csm_xy(wks,x,y,res)
   ...

Of course, it would be better if you could accomplish the assignments
inside a single loop, so you don't have to hardcode each index of x
and y this way.

--Mary

On Thu, 5 Apr 2007, Lawrence wrote:

> Hi Ozan
>
> Thank you for your reply, and what you told me do work for two different
> datasets. However ,my problem is I have several model data that need to be
> plot. So is there any more suggestions? Thanks!
>
> Regards
> Lawrence
>
>
> 2007/4/5, ozan mert gokturk <gokturko_at_itu.edu.tr>:
>>
>> Hi Lawrence,
>>
>> Try this:
>>
>> http://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_csm_x2y.shtml
>>
>> cheers,
>>
>> --Ozan
>>
>>
>>
>> Quoting Lawrence <diurnal1722_at_gmail.com>:
>>
>> > Dear NCL users,
>> > I want to draw a multi-line XY plot, say the x-axis is longitude
>> and
>> > the y-axis is precipitation. The problem is the longitude for the
>> models
>> > data is different, i.e. the number of x-axis is not the same. I don't
>> want
>> > to interpolate them into the same grid, because the interpolation may
>> smooth
>> > the signal I need. Is there any way to do this? Any suggestion will be
>> > appreciated.
>> >
>> > Regards,
>> > Lawrence
>> >
>>
>>
>>
>> ----------------------------------------------------------------
>> This message was sent using IMP, the Internet Messaging Program.
>>
>>
>
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Apr 09 2007 - 08:59:28 MDT

This archive was generated by hypermail 2.2.0 : Wed Apr 11 2007 - 08:36:47 MDT