[ncl-talk] Difficulty overlaying xy line overtop polygon and background text

Andrew Kren - NOAA Federal andrew.kren at noaa.gov
Fri Sep 10 05:57:35 MDT 2021


Thanks Adam, I am going to try this and let you know.

On Tue, Sep 7, 2021 at 4:53 PM Adam Phillips <asphilli at ucar.edu> wrote:

> Hi Andrew,
> I (unfortunately) have plenty of experience with draw order issues with
> polygons, polylines and text. It can get quite frustrating. If memory
> serves, there's a weird quirk where NCL only listens to one tfPolyDrawOrder
> setting for all polygons/polymarkers/polylines/gsn*text, regardless if you
> set this 3 different ways in 3 different resource lists.
>
> You spoke of two issues you are having:
> *1 - When the polygons get drawn, regardless of whether I set the draw
> order to PreDraw or not, they are on top of the xyline and the
> points/labels.*
> I don't see this issue in the plot you sent, so I must be missing
> something. The orange line is on top of the green and beige polygon boxes.
>
> *2 - The other issue I have is that I am trying to get the xy-line and the
> point labels to be on top of the text that I overlay (such as the
> "Elevated" label in the attached image).*
> This issue I do see, as the "8" on the 7am Monday reading is getting
> overwritten by the "Elevated" text.
>
> Things to try (in no particular order):
> 1 - For any text that you want to be on top (and overlay everything else)
> call these sections of code *after* you call draw(plot). This
> technically should fail, but it's a work around I've used successfully
> before.
> 2 - Along the same lines, try moving different code sections around,
> calling the text/polylines etc that you want on top as near to the end as
> possible. Again, the order of your code shouldn't alter anything, but
> sometimes it does.
> 3 - If this is going to be a static image, the sizes of everything are not
> changing and the NDC coordinates of anything will not change, and you are
> not paneling, the big hammer would be to draw the polygons, the gsn_csn_xy
> line, the line value labels, and the legend. Then call draw(plot), but then
> use gsn_text_ndc to place the "High/Moderate..." exactly where you want it.
> 4 - Use gsn_add_text instead of gsn_text if you can.
>
> This is definitely a weakness in NCL's graphics. It would be great if NCL
> had something akin to what is done with other software with layers, where
> you can say put this label on top of this line on top of this polygon and
> so on.  When I have a number of polygon/polyline/polymarker calls, and I
> have to mess with the draw order of the various objects, I know that
> there's a good chance that I will have to partake in a fair bit of trial
> and error.  Hopefully you are able to figure things out.
> Hope the above helps,
> Adam
>
>
>
>
>
> On Sun, Sep 5, 2021 at 8:36 AM Andrew Kren - NOAA Federal via ncl-talk <
> ncl-talk at mailman.ucar.edu> wrote:
>
>> Hi ncl-talk,
>>
>> Sorry for the bother. I am making an xy plot where I plot the xy-line
>> along with points labeling the values at certain intervals. I am
>> overlapping polygons to specify different levels of the xy values using
>> gsn_add_polygon. When the polygons get drawn, regardless of whether I set
>> the draw order to PreDraw or not, they are on top of the xyline and the
>> points/labels. I even set my xyline draw order to PostDraw and that does
>> not seem to alleviate it. The other issue I have is that I am trying to get
>> the xy-line and the point labels to be on top of the text that I overlay
>> (such as the "Elevated" label in the attached image). I was not able to
>> find a setting to set the draw order of text so any input is appreciated.
>>
>> I appreciate any help you can provide. I attached my script for
>> convenience.
>>
>> --
>>
>> Andrew Kren
>> Meteorologist
>> NOAA's National Weather Service
>> Raleigh Forecast Office
>> 1005 Capability Drive, Suite 300
>> Raleigh, North Carolina 27606
>> voice: 919-326-1035
>> mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at mailman.ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> https://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
>
> <http://www.cgd.ucar.edu/staff/asphilli>
>


-- 

Andrew Kren
Meteorologist
NOAA's National Weather Service
Raleigh Forecast Office
1005 Capability Drive, Suite 300
Raleigh, North Carolina 27606
voice: 919-326-1035
mailto: andrew.kren at noaa.govhttp://www.weather.gov/rah
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20210910/a32e40fe/attachment.html>


More information about the ncl-talk mailing list