[ncl-talk] Duplicate a plot

Mary Haley haley at ucar.edu
Fri Oct 6 13:25:46 MDT 2017


It's dangerous to do:

plot2 = plot1

to make a copy, because in this case, they do point to the same object.
This means if you change plot2, you will also change plot1, but maybe not
in the way you'd expect.

Try the attached script, which makes a copy of plot2 and then changes its
color map.  Note how even though I didn't change plot1, the color map is
now the one set in plot2. However, the labelbar is from the original color
map because it didn't get regenerated.

--Mary


On Fri, Oct 6, 2017 at 8:39 AM, Carl Schreck <cjschrec at ncsu.edu> wrote:

> I still got the error with "copy", but it's no worries to just create it
> again.
>
> On Thu, Oct 5, 2017 at 12:58 PM, Dennis Shea <shea at ucar.edu> wrote:
>
>>
>> plot1 = gsn_csm_xy(...
>> plot2 = gsn_csm_xy(...
>> plot3 = gsn_csm_xy(...
>>
>> PLOT1= plot1   ; 'copy' rather than 'creae't
>>
>> overlay(plot2,plot1)
>> overlay(plot3,PLOT1)
>>
>> On Thu, Oct 5, 2017 at 9:57 AM, Adam Phillips <asphilli at ucar.edu> wrote:
>>
>>> Hi Carl,
>>> In short: No, you will have to create the same plot (=plot1) twice. Once
>>> a plot has been overlaid once you can not overlay it again.
>>> Adam
>>>
>>> On Wed, Oct 4, 2017 at 9:50 AM, Carl Schreck <cjschrec at ncsu.edu> wrote:
>>>
>>>> I am making one plot that I want to overlay onto two other ones. When I
>>>> draw the other two, say:
>>>>
>>>> plot1 = gsn_csm_xy(...
>>>> plot2 = gsn_csm_xy(...
>>>> plot3 = gsn_csm_xy(...
>>>>
>>>> overlay(plot2,plot1)
>>>> overlay(plot3,plot1)
>>>>
>>>> And this gives me an error:
>>>> fatal:NhlAddOverlay: tranform is already an annotation or overlay: 30
>>>>
>>>> Is there a way to duplicate plot1 other than creating it from scratch
>>>> again? Just doing plot1b = plot1 and then overlaying plot1b doesn't
>>>> fix it.
>>>>
>>>> Thanks!
>>>> Carl
>>>>
>>>> --
>>>>
>>>>
>>>> <https://ncics.org/>
>>>> * Cyclone <http://www.cyclonecenter.org/>*Center.org
>>>> <http://www.cyclonecenter.org/>   *Carl J. Schreck III, PhD*
>>>> *Research Scholar / Research **Assistant Professor*
>>>> Cooperative Institute for Climate and Satellites NC (CICS
>>>> <http://www.cicsnc.org/>*-NC) <http://www.cicsnc.org/> /*
>>>> Department of Marine, Earth, and Atmospheric Sciences (MEAS)
>>>> <https://meas.sciences.ncsu.edu/>
>>>> North Carolina State University <http://ncsu.edu/>
>>>> NOAA National Centers for Environmental Information (NCEI)
>>>> <http://ncei.noaa.gov/>
>>>> 151 Patton Ave, Asheville, NC 28801
>>>> <https://maps.google.com/?q=151+Patton+Ave,+Asheville,+NC+28801&entry=gmail&source=g>
>>>> e: carl_schreck at ncsu.edu
>>>> o: +1 828 257 3140 <(828)%20257-3140>
>>>> c: +1 828 484 1702 <(828)%20484-1702>
>>>> Publications
>>>> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
>>>> ncics.org/mjo
>>>>
>>>> _______________________________________________
>>>> 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 <(303)%20497-1726>
>>>
>>> <http://www.cgd.ucar.edu/staff/asphilli>
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
>
>
> <https://ncics.org/>
> * Cyclone <http://www.cyclonecenter.org/>*Center.org
> <http://www.cyclonecenter.org/>   *Carl J. Schreck III, PhD*
> *Research Scholar / Research **Assistant Professor*
> Cooperative Institute for Climate and Satellites NC (CICS
> <http://www.cicsnc.org/>*-NC) <http://www.cicsnc.org/> /*
> Department of Marine, Earth, and Atmospheric Sciences (MEAS)
> <https://meas.sciences.ncsu.edu/>
> North Carolina State University <http://ncsu.edu/>
> NOAA National Centers for Environmental Information (NCEI)
> <http://ncei.noaa.gov/>
> 151 Patton Ave, Asheville, NC 28801
> e: carl_schreck at ncsu.edu
> o: +1 828 257 3140 <(828)%20257-3140>
> c: +1 828 484 1702 <(828)%20484-1702>
> Publications
> <http://scholar.google.com/citations?hl=en&user=th8ONEcAAAAJ&view_op=list_works&sortby=pubdate>
> ncics.org/mjo
>
> _______________________________________________
> 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/20171006/02006e2f/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: plot_copy.ncl
Type: application/octet-stream
Size: 700 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20171006/02006e2f/attachment.obj>


More information about the ncl-talk mailing list