Re: DrawOrder

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Thu Jul 04 2013 - 21:35:44 MDT

Verena,

Using the annotate_2.ncl script I sent you as an example, I modified your "index.ncl" code so that two blank plots are created, with the same size and axis limits as your XY plots. I added the two gray boxes to these blank plots, and then overlaid the XY plots on the blank plots, hence forcing the gray box to be on the bottom.

See attached.

--Mary

On Jul 3, 2013, at 12:50 AM, Verena Lili <verena.prick@gmail.com> wrote:

> Hi Everyone,
>
> I still have problem to produce the polygon behind my bar (gsn_csm).
> I really appreciate if one of you has an idea to solve it.
>
> I attached here my clean code and the test data can be directly downloaded from
>
> ftp://ftp.cdc.noaa.gov/Datasets/ncep.reanalysis2.derived/pressure/air.mon.mean.nc
>
> thank you.
>
> Regards,
> Verena.
>
>
>
>
>
>
>
>
> On Mon, Jul 1, 2013 at 11:47 PM, Mary Haley <haley@ucar.edu> wrote:
> Here's a script that I threw together in a hurry, using the "annotate_2.ncl" one on our website. It uses gsn_blank_plot to create a plot with the gray box.
>
> Let me know if you have any questions about what I did.
>
> --Mary
>
>
>
> On Jul 1, 2013, at 8:18 AM, Mary Haley <haley@ucar.edu> wrote:
>
>> Hi Verena,
>>
>> Whenever you add primitives to a plot via gsn_add_polyxxxx, they can all only be in one draw order phase. So, the draw order is then determined by when they are added to the plot.
>>
>> I *think* the problem is, then, that since the filled bar charts are polygons added with gsn_add_polygon, and the gray area you added was done also with gsn_add_polygon, it is getting drawn last because it was added last.
>>
>> First, just to see if it works, try using "PreDraw" as the value, rather than "Draw".
>>
>> If that doesn't work, then I may have to suggest something more complicated in order to force the gray bar to be drawn first. This might involve creating a blank plot using "gsn_csm_blank_plot", adding the gray bars to that, and then creating your bar chart as usual, and then adding the bar chart on top of the gray blank plot using gsn_add_annotation.
>>
>> If you get to that point and are not sure what I'm talking about, then can you provide me with your script and data, and I'll show you how to do it.
>>
>> You can use our ftp to upload the files:
>>
>> http://www.ncl.ucar.edu/report_bug.shtml#HowToFTP
>>
>> Thanks,
>>
>> --Mary
>>
>> On Jun 30, 2013, at 11:33 AM, Verena Lili <verena.prick@gmail.com> wrote:
>>
>>> Hallo NCL,
>>>
>>> Sorry fow a simple question. I just wonder why the draworder did not solve
>>> my problem to put the polygon behind the bar chart. Here is my resources settings:
>>>
>>>
>>> wks = gsn_open_wks ("pdf", "bar" )
>>> res = True
>>> res@gsnScale = True
>>> plot = new(2,graphic)
>>>
>>> res@gsnDraw = False ; don't draw
>>> res@gsnFrame = False
>>>
>>>
>>> res@vpXF = 0.14 ; In page coordinates, where to start
>>> res@vpYF = 0.75 ; the plot
>>> res@vpHeightF = 0.43 ; Changes the aspect ratio
>>> res@vpWidthF = 0.85
>>>
>>> res@trYMinF = -3.0 ; min value on y-axis
>>> res@trYMaxF = 3.0 ; max value on y-axis
>>>
>>> res@tiYAxisString = "Time" ; y-axis label
>>> res@tiMainString = " " ; title
>>> res@gsnLeftString = "DJF"
>>>
>>> res@gsnYRefLine = 0. ; reference line
>>> res@gsnXYBarChart = False ; create bar chart
>>> res@gsnAboveYRefLineColor = "red" ; above ref line fill red
>>> res@gsnBelowYRefLineColor = "blue" ; below ref line fill blue
>>>
>>> ;===============================================================================
>>>
>>> nk = 32
>>> time = ispan(1980,2011,1)
>>>
>>> xp = new( (/2*nk/), float )
>>> yp = new( (/2*nk/), float )
>>>
>>> do i=0,nk-1
>>> yp(i) = 3*climJFM(0)
>>> xp(i) = time(i)
>>> xp(2*nk-1-i) = time(i)
>>> yp(2*nk-1-i) = -3*climJFM(0)
>>> end do
>>>
>>> nk1 = 32
>>> time1 = ispan(1980,2011,1)
>>>
>>> xp1 = new( (/2*nk1/), float )
>>> yp1 = new( (/2*nk1/), float )
>>>
>>> do i=0,nk1-1
>>> yp1(i) = 1*climJFM(1)
>>> xp1(i) = time(i)
>>> xp1(2*nk1-1-i) = time(i)
>>> yp1(2*nk1-1-i) = -1*climJFM(1)
>>> end do
>>>
>>> ;===============================================================================
>>>
>>> plot(0) = gsn_csm_xy (wks,ispan(1980,2011,1),JFM(0,:),res)
>>>
>>> res@gsnLeftString = "MAM"
>>> delete(res@tiMainString)
>>>
>>> gsres = True ; poly res
>>> gsres@tfPolyDrawOrder = "Draw" ; draw this first
>>> gsres@gsFillColor = "SlateGray"
>>> dummy = gsn_add_polygon (wks,plot(0),xp,yp,gsres)
>>>
>>>
>>> plot(1) = gsn_csm_xy (wks,ispan(1980,2011,1),JFM(1,:),res)
>>>
>>> gsres1 = True ; poly res
>>> gsres1@tfPolyDrawOrder = "Draw" ; draw this first
>>> gsres1@gsFillColor = "SlateGray"
>>> dummy1 = gsn_add_polygon (wks,plot(1),xp1,yp1,gsres1)
>>>
>>> gsn_panel(wks,plot,(/2,1/),False)
>>> end
>>>
>>> thank you,
>>>
>>>
>>>
>>> --
>>> Regards,
>>> Dr. Verena.
>>>
>>> <bar.png>_______________________________________________
>>> ncl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
>
>
>
> --
> Regards,
> Dr. Verena.
> School of Marine and Atmospheric Sciences
> Stony Brook University
> homepage: http://metsci.tk
>
>
>
> --
> Regards,
> Dr. Verena.
> School of Marine and Atmospheric Sciences
> Stony Brook University
> homepage: http://metsci.tk
> <index.ncl>_______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Thu Jul 4 21:35:54 2013

This archive was generated by hypermail 2.1.8 : Fri Jul 05 2013 - 13:06:49 MDT