Re: Add markers or curves to existing xy2 plot array

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 17 2014 - 17:27:31 MDT

Hi Wenshan,

The issue, of course, is that the array of plot objects, like any variable
array in NCL, has only a single set of attributes for all members of the
array. In the case of arrays of graphic objects, the attributes of the
first element become the attributes of the array as a whole.

What I suggest is that when you call gsn_csm_xy2, you initially assign it
to a scalar variable, say plot. Then you also have two graphic arrays,
one that you put plot into, and the other you put plot@xy2 into:

do i, num_plots-1
   plot = gsn_csm_xy2,(wks, ....
   plots(i) = plot
   plots2(i) = plot@xy2

end do


I am attaching a modified version of the example xy_7.ncl to illustrate.
Hope this helps.
 -dave











On Thu, Jul 17, 2014 at 11:53 AM, Wenshan Wang <wenshanw@uci.edu> wrote:

> Hi Karin,
>
> Thank you very much for your help.
>
> I mean on my left axis it is temperature, on the same plot but right axis
> it is pressure.
> I want to add temperature markers to the left axis and pressure markers t=
o
> the right axis.
>
> If my plot is scalar, it is easy. just:
> dum1 = gsn_add_polymarker(wks,plot,x,temperature,res1)
> dum2 = gsn_add_polymarker(wks,*plot@xy2*,x,pressure,res1)
>
> But if plot is an array, I don't how to do it.
> I will write a sample script today.
>
> Thank you!
>
> Best,
> Wenshan
>
> -------------------------------------------------------------------------=
-----
> Graduate Student Researcher
> Earth System Science
> University of California, Irvine
>
>
> On Thu, Jul 17, 2014 at 12:47 AM, Karin Meier-Fleischer <
> meier-fleischer@dkrz.de> wrote:
>
>> Hi Wenshan,
>>
>> ok, let me see if I understand it right. You want to create xy2 plots an=
d
>> add 2 marker to
>> each single plot. Within a loop you have to be sure that the names of th=
e
>> variables (dum_left,
>> dum_right) containing the graphical information of the marker are unique=
.
>>
>> do i=0,n
>> plot(i) = gsn_csm_xy2(...)
>> *dum_left* = unique_string("markl")
>> *plot1*@*$dum_left$* = gsn_add_polymarker(wks,plot(i),x,y1,res1)
>> *dum_right* = unique_string("markr")
>> *plot1*@*$dum_right$* = gsn_add_polymarker(wks,plot(i),x,y2,res1)
>> end do
>>
>> Hope this helps. If not, please send the script and your data (if
>> possible), because it is very
>> difficult to help without knowing it.
>>
>> Bye,
>> Karin
>>
>> Am 17.07.14 06:36, schrieb Wenshan Wang:
>>
>> Hi Karin,
>>
>> Which one exactly do you mean?
>> Sorry I didn't see any one that can solve my problem here.
>>
>> Let me see if I can explain my situation better.
>> I have several panels on one page. On each panel, the XY plot has two
>> different y-axes.
>> I use:
>> do i = 0, n
>> plot(i) = gsn_csm_xy2(...)
>> end do
>>
>> Then I want to add markers to each panel on both y-axes.
>> Basically, I want something like
>> 1 do i = 0, n
>> 2 plot(i) = gsn_csm_xy2(...)
>> 3 dum_left(i) = gsn_add_polymarker(wks, plot(i), x, y1, res1)
>> 4 dum_right(i) = gsn_add_polymarker(wks, *plot(i)@xy2*, x, y2, res2)
>> 5 end do
>>
>> but of course, line 4 is not right in syntax.
>> I was wondering whether there is a way to do so.
>>
>> Thank you very much for your time!
>>
>> Best,
>> Wenshan
>>
>> ------------------------------------------------------------------------=
------
>> Graduate Student Researcher
>> Earth System Science
>> University of California, Irvine
>>
>>
>> On Wed, Jul 16, 2014 at 2:19 PM, Karin Meier-Fleischer <
>> meier-fleischer@dkrz.de> wrote:
>>
>>> Hi Wenshan,
>>>
>>> take a look at the examples of the gsn_add_polymarker page:
>>>
>>>
>>> https://www.ncl.ucar.edu/Document/Graphics/Interfaces/gsn_add_polymarke=
r.shtml
>>>
>>> Bye,
>>> Karin
>>>
>>> Am 16.07.2014 um 22:51 schrieb Wenshan Wang <wenshanw@uci.edu>:
>>>
>>> Hi NCL users,
>>>
>>> I was wondering how to add markers or curves to an existing XY plot
>>> with two different y/x axes.
>>> I find how to do it with scaler plot from xy_25.ncl and xy_26.ncl:
>>>
>>> dum1 = gsn_add_polyline(wks,plot@xy2,time,p1,lnres)
>>>
>>> What if my plot is an array?
>>> I tried plot(i)@xy2 or plot@xy2(i); but they didn't work, actually as I
>>> expected.
>>> So it there a way to complete this?
>>>
>>> Thank you!
>>>
>>> Best,
>>> Wenshan
>>>
>>> -----------------------------------------------------------------------=
-------
>>> Graduate Student Researcher
>>> Earth System Science
>>> University of California, Irvine
>>> _______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>>
>>>
>>
>> --
>> Dipl. Geophys. Karin Meier-Fleischer
>> Application Support, Visualization
>>
>> Deutsches Klimarechenzentrum GmbH E-Mail: meier-fleischer@dkrz.de
>> Bundesstrasse 45a Internet: http://www.dkrz.de/
>> 20146 Hamburg Phone: +49 (0)40 460094 126
>> Germany Fax: +49 (0)40 460094 270
>>
>> Geschäftsführer: Prof. Dr. Thomas Ludwig
>> Sitz der Gesellschaft: Hamburg
>> Amtsgericht Hamburg HRB 39784
>>
>>
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>

Received on Thu Jul 17 11:27:38 2014

This archive was generated by hypermail 2.1.8 : Fri Aug 01 2014 - 15:10:55 MDT