[ncl-talk] Plotting polygons on xy plot

Andrew Kren - NOAA Affiliate andrew.kren at noaa.gov
Fri Apr 21 11:11:19 MDT 2017


I figured it out Mary!

On Fri, Apr 21, 2017 at 8:47 AM, Andrew Kren - NOAA Affiliate <
andrew.kren at noaa.gov> wrote:

> Thanks Mary. I got my bars to show up now and my colors are plotting
> corrrectly. I still have the issue of the plot showing up twice on top of
> itself. Do you know why that could be? I am looking it over as I email
> this, but currently can't figure it out. Also, I can't figure out why the X
> reference line does not show up. See attached.
>
> Thanks for your help,
>
> On Thu, Apr 20, 2017 at 5:30 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Andrew,
>>
>> You are close.
>>
>>  In order for all the polygons to show up, the return value from
>> gsn_add_polygon must be unique.
>>
>> You have the gsn_add_polygon call inside a double do loop, and inside of
>> the innermost loop you have:
>>
>>     dum2 = new(dimsizes(temp_variable_3),graphic)
>>
>> and then later:
>>
>>     dum2(a) = gsn_add_polygon(wks,plot_without_ygrid,xbar,ybar,bres)
>>
>> What's happening is that for each iteration of "a", dum2 is being reset
>> to an empty array. Any previous calls to gsn_add_polygon have been
>> effectively wiped out.
>>
>> Also, given that you have two do loops, you will need to move this dum2
>> call to outside of both do loops and make it big enough to accommodate both
>> loops:
>>
>> ntvar3 = dimsizes(temp_variable_3)
>> nregns = 5
>> dum2   = new((/nregns,ntvar3/),graphic)
>>
>> do i=0,nregns-1 ; loop over regions
>> . . .
>>
>> do a=0,ntvar3-1 ; loop over all values for this region
>>
>>  . . .
>>  dum2(i,a) = gsn_add_polygon(wks,plot_without_ygrid,xbar,ybar,bres)
>>   . . .
>> end do
>> . . .
>> end do
>>
>> Another way to do this that doesn't involve creating a "dum2" variable is
>> to use "unique_string" to create a unique name, and then use this unique
>> name as an attribute to any variable that holds the return value from
>> gsn_add_polygon. I usually use the "plot" variable:
>>
>>  plot@$unique_string("polygon")$ = gsn_add_polygon(wks,plot_witho
>> ut_ygrid,xbar,ybar,bres)
>>
>>
>> Hopefully by fixing this, your other issues with colors will resolve
>> themselves.
>>
>> --Mary
>>
>>
>>
>>
>> On Thu, Apr 20, 2017 at 4:51 PM, Andrew Kren - NOAA Affiliate <
>> andrew.kren at noaa.gov> wrote:
>>
>>> Dear ncl-talk,
>>>
>>> I am trying to plot a number of polygons on an xy plot, but for some
>>> reason, the polygons are not showing up. The only one that shows up is the
>>> last one. Also, the colors don't seem to work correctly, as they are all
>>> red and not varying based on my color array. The other problem is that the
>>> plot seems to be plotting twice and I can't figure out why. Attached is the
>>> figure and the program. The program is long so the only issue in the
>>> program starts at line 3148 and ends at 3209.
>>>
>>> Thanks much,
>>>
>>> --
>>> Andrew Kren, PhD
>>> Research Scientist I, Global Observing Systems Analysis (GOSA) Group
>>> NOAA ESRL Global Systems Division (Rm 3C515)
>>> 325 Broadway, Boulder, CO 80305
>>> (303) 497-5418
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
>
> --
> Andrew Kren, PhD
> Research Scientist I, Global Observing Systems Analysis (GOSA) Group
> NOAA ESRL Global Systems Division (Rm 3C515)
> 325 Broadway, Boulder, CO 80305
> (303) 497-5418
>



-- 
Andrew Kren, PhD
Research Scientist I, Global Observing Systems Analysis (GOSA) Group
NOAA ESRL Global Systems Division (Rm 3C515)
325 Broadway, Boulder, CO 80305
(303) 497-5418
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170421/fdf163d0/attachment.html 


More information about the ncl-talk mailing list