[ncl-talk] Multi-line plot with different time length of data
Rick Brownrigg
brownrig at ucar.edu
Thu May 30 11:35:11 MDT 2019
Hi,
One possibility would be to load the shorter 5th array's data into an array
the same size as the rest, but set the first twelve values (862-850 to
missing values; that is @_FillValue
as demonstrated by the script below:
Rick
; ***********************************************
; xy_1.ncl
;
; Concepts illustrated:
; - Drawing a black-and-white XY plot
;
;************************************************
; These files are loaded by default in NCL V6.2.0 and newer
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
; load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
;************************************************
begin
;************************************************
; read in data
;************************************************
f = addfile ("$NCARG_ROOT/lib/ncarg/data/cdf/uv300.nc","r")
u = f->U ; get u data
;************************************************
; plotting parameters
;************************************************
wks = gsn_open_wks ("x11","xy") ; send graphics to PNG file
res = True ; plot mods desired
res at tiMainString = "Basic XY plot" ; add title
plot = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ; create plot
u(0,0:15,{82}) = u at _FillValue
plot = gsn_csm_xy (wks,u&lat,u(0,:,{82}),res) ; create plot
end
On Thu, May 30, 2019 at 8:36 AM S Br <sbr.climate at gmail.com> wrote:
> Hi All,
> I am doing a multi-line plot with 5 different sets of data. All my data
> has annual mean values.
> 4 sets of data extends for the period 850-2005, where as the 1 sets of
> data extends for the period 862-2005.
> In the line plot, the first 4 sets of data should start at year 850, where
> the 5th line should start at year 862. I am doing following things but all
> line starts from year 850.
> Could you please suggest how to start first 4 lines from 850 and the 5th
> line from year 862.
>
> temp1 = f1->tos(:,0,0)
> printVarSummary (temp1)
> temp2 = f2->tos(:,0,0)
> temp3 = f3->tos(:,0,0)
> temp4 = f4->tos(:,0,0)
> temp5 = f5->tos(:,0,0)
>
> time = ispan(850,2005,1)
> time at long_name = "Time"
>
> data = new((/5,1156/),float)
> data(0,0:1155) = temp1
> data(1,0:1155) = temp2
> data(2,0:1155) = temp3
> data(3,0:1155) = temp4
> data(4,0:1138) = temp5
>
> wks = gsn_open_wks("X11", "Multiline_NCL")
>
> res = True
> res at xyXStyle = "Time"
>
> ;-- create plot
> plot = gsn_csm_xy(wks,time,data,res)
>
> Thank you.
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20190530/d67d47e3/attachment.html>
More information about the ncl-talk
mailing list