[ncl-talk] [ncarg-talk] Regarding Panel Plot of the Overlaid XY Plot

Mary Haley haley at ucar.edu
Fri Nov 2 10:35:39 MDT 2018


Dear Atul Saini,

Please post all follow-up messages back to the email list.  I CC'ed
ncl-talk instead of ncl-install in this case, because this is a usage
question.

There are a few ways you can add more curves to an existing XY plot. See
examples xy_25.ncl, xy_overlay_25.ncl (which I added for you), and
xy_26.ncl at:

http://www.ncl.ucar.edu/Applications/xy.shtml#ex25
http://www.ncl.ucar.edu/Applications/xy.shtml#exoverlay25
http://www.ncl.ucar.edu/Applications/xy.shtml#ex26

The xy_overlay_25.ncl should answer the question you have

--Mary




On Fri, Nov 2, 2018 at 1:20 AM, Atul Saini <atulsainimail at gmail.com> wrote:

> Thanks a lot respected sir, your guidance is of high imporance to me.
>
> Sir, in view of the script sent by you for two overlapping variables and
> therir panel plot, I would like to know what should be done if the
> variables to be overlapped are more than 2 e.g. total 4 variables i.e.
> tmin,tmean,tmax and rf?
>
> SIR, Your reply is of high value to me
>
> On Fri, Nov 2, 2018, 03:00 Mary Haley <haley at ucar.edu wrote:
>
>> In the future, please post NCL questions to ncl-talk at ucar.edu.
>> ncl-install is for installation issues.
>>
>> You have several errors in your script:
>>
>>
>> [0] You are using "draw" as variable name.  "draw" is a reserved keyword
>> in NCL, because it's a procedure that you call to draw plots. Hence you
>> can't use it as a variable name. However, this variable is not really
>> needed as I think you are creating more plots than you need to. Instead of
>> calling gsn_csm_xy and gsm_csm_xy2 and overlaying the two plots, I think
>> all you need is to call:
>>
>> plot1=gsn_csm_x2y2(wks,tmean_yfrac,raf_yfrac,tmeann,raf,resmn,resr)
>>
>>
>> However, note that I have created two variables: tmean_yfrac and
>> raf_yfrac. I converted the "time" variable of both variables to be a
>> fractional year value, and noticed the two arrays were different, so you
>> have to be careful about plotting them using a common "time" variable.
>> Using gsn_csm_x2y2 allows me to specify a unique X and Y array for both
>> curves.
>>
>>
>> [1] You can't have a space after the "@" sign when setting attributes:
>>
>>  resmn@ tmXUseBottom =False
>>
>> This should be:
>>
>>  resmn at tmXUseBottom =False
>>
>> [2] These lines are wrong:
>>
>>  draw(1)=gsn_csm_xy2(wks,yyyy,tmeann,raf,resmn,resr)
>>  overlay(plot(1),draw(1))
>>  plot(1)
>>
>>
>> First, the "draw" variable will have been renamed to "plot2". Second,
>> just calling "plot(1)" makes no sense. I think what you wanted was:
>>
>>  plot2(1)=gsn_csm_xy2(wks,yyyy,tmeann,raf,resmn,resr)
>>  overlay(plot(1),draw(1))
>>  draw(plot(1))
>>
>>
>> [3] If you are trying to put two plots in a panel, then they must both
>> have the same "wks" variable associated with it. There's no reason to
>> create two separate workstations.
>>
>> [4] When you call gsn_panel, you only want to give it the plots you want
>> to panel. You passed in "plot" which consists of two base plots and two
>> overlaid plots.  You can't draw plots once they've been overlaid, so what
>> you want is:
>>
>> gsn_panel(wks,(/plot(1),plot(3)/),(/1,2/),False)
>>
>>
>> [5] You are getting a number of warnings when you run the script, because
>> you are setting resources that have no meaning for the type of plot being
>> created. For example, you set "gsMarkerIndex", but this resource is only
>> good for when you are adding markers to a plot via "gsn_polymarker" or
>> "gsn_add_polymarker".  If you are trying to set a marker for an XY plot,
>> then this should be:
>>
>> resmn at xyMarker = 1
>> resr at xyMarkLineMode = "MarkLines"
>>
>>
>> I set xyMarkLineMode to "MarkLines" because otherwise you will only get
>> lines.  If you only want markers, then set:
>>
>> resr at xyMarkLineMode = "Markers"
>>
>>
>> [6] There are no resources called "tbXMaxF" or "tbXMinF".  I think you
>> meant "trXMaxF" and "trXMinF".
>>
>> You need to be careful about resource misspellings. NCL will tell you if
>> it doesn't recognize a resource you are setting, with this kind of warning:
>>
>> warning:tbXminF is not a valid resource in overlay_chamba_and_kangra_plots_xy
>> at this time
>>
>>
>> [7] The rest aren't really errors, but things I did to clean up the plot
>>
>> - I set vpWidthF and vpHeightF so that you get a plot that is wider than
>> it is high.  This is usually done for time series plots. If you don't like
>> this, simply remove or comment all lines with these resources, and you will
>> get the default square plot.
>>
>>  - I changed the panel so that the two plots are being drawn in two rows
>> and one column.
>>
>>  - I set some other resources to turn off the top labels and tickmarks.
>>
>>  - I changed the color of the Y axis strings to match the color of their
>> corresponding curves. This was mainly for me, to make sure I had the
>> correct curve with the correct axis.
>>
>>  - I noticed you are setting resr and resmn resource lists twice and
>> setting them to exactly the same thing, with the exception of the main
>> title (tiMainString). I removed the duplicate settings to clean things up.
>>
>> - I reorganized the resources so they are hopefully easier to read and
>> modify later.
>>
>>  - You may want to set trYMinF / trYMaxF for one or both axes depending
>> on how you want the two curves displayed relative to each other.
>>
>> See the attached modified script and resultant plot.
>>
>> If you continue to have problems, please post them to ncl-talk. You must
>> subscribe first:
>>
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> --Mary
>>
>>
>>
>> On Tue, Oct 30, 2018 at 10:26 PM, Atul Saini <atulsainimail at gmail.com>
>> wrote:
>>
>>> Respected Sir/Ma'am,
>>>                        It is my humble request to guide me in the
>>> following issue.
>>>
>>> Sir/Ma'am, I am overlaying xy plot {  plot (2) over plot(1) and plot(3)
>>> over plot(4)   }  and then trying to get plot(1) and plot (3) in the panel
>>> plot.
>>>
>>> The NCL code along with the required data files for the purpose are
>>> attached herewith this mail.
>>>
>>> *I don't know what is the problem with the code, please help .*
>>>
>>>
>>>
>>>
>>> Regards,
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> ncarg-talk mailing list
>>> ncarg-talk at ucar.edu
>>> http://mailman.ucar.edu/mailman/listinfo/ncarg-talk
>>>
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20181102/ce018201/attachment.html>


More information about the ncl-talk mailing list