[ncl-talk] adding legends to xy plot
Adam Phillips
asphilli at ucar.edu
Fri Aug 28 09:23:57 MDT 2015
Hi Tabish,
The data array that you are passing in is dimensioned 49 x49. I think you
want that to be dimensioned 2 x 49. Change this:
data = new((/49,49/),"float")
to this:
data = new((/2,49/),"float")
(If you do not do that you will get 49 labeled legend lines.)
If that doesn't solve your issue or if you have further questions please
respond to ncl-talk.
Adam
On Thu, Aug 27, 2015 at 9:54 AM, Tabish Ansari <tabishumaransari at gmail.com>
wrote:
> Hi
>
> I am using the following script:
>
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"
> load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"
>
> begin
> a = addfile ("consolidated_d04.nc","r")
> wks = gsn_open_wks ("x11","xy") ; open workstation
> res = True ; plot mods desired
> res at tiMainString = "PM2.5 at Mandir Marg" ; add title
> res at xyLineColors = (/"blue","red"/) ; change line color
> res at xyDashPattern = 0 ; Make curves all solid
> res at xyLineThicknesses = (/2.0,2.0/) ; make 2nd lines thicker
> res at pmLegendDisplayMode = "Always" ; turn on legend
> res at xyExplicitLegendLabels = (/"Sim.","Obs."/) ; create explicit
> labels
>
> time = fspan(0, 48, 49)
> data = new((/49,49/),"float")
> PM25_sim = a->PM25(:,0,38,37)
> PM25_obs = asciiread("PM2_5_MM.txt",(/49/),"float")
> data(0,:)= PM25_sim
> data(1,:)= PM25_obs
> plot = gsn_csm_xy (wks,time,data,res) ; create plot
> end
>
>
> However, I
> am not getting the desired legend names.
>
> Please help me out
>
> Thanks a lot
>
> Tabish
>
>
>
>
> Tabish U Ansari
> IBM Research India Laboratory
> New Delhi
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
Adam Phillips
Associate Scientist, Climate and Global Dynamics Laboratory, NCAR
www.cgd.ucar.edu/staff/asphilli/ 303-497-1726
<http://www.cgd.ucar.edu/staff/asphilli>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150828/76b00d45/attachment.html
More information about the ncl-talk
mailing list