[pyngl-talk] Fill color between 2 lines with Ngl.xy

Mary Haley haley at ucar.edu
Thu Aug 30 18:10:20 MDT 2018


Sorry, the minute I sent this I realized I had cut off the X axis title
from the bottom plot. I've attached a better script and image (I hope).

--Mary


On Thu, Aug 30, 2018 at 6:06 PM, Mary Haley <haley at ucar.edu> wrote:

> I think the simple answer is that you need to make sure the contour fill
> draw happens before the XY fill happens.
>
> res.cnFillDrawOrder = "PreDraw"
>
> There are three phases that various aspects of the plots get drawn in:
> "PreDraw", "Draw" and "PostDraw".
>
> If you make sure the contour fill draw happens in the "Predraw" phase, and
> the XY fill in the "PostDraw" phase, then it should work.
>
> If both things fall in the PostDraw phase, then I'm not exactly sure what
> the ordering is of those elements.
>
> I've attached a sample program and PNG file (which is not very interesting
> because it uses dummy data).
>
> --Mary
>
>
> On Thu, Aug 30, 2018 at 4:57 PM, Mary Haley <haley at ucar.edu> wrote:
>
>> Hi Matt,
>>
>> I'm looking into this one; I don't think we have an example in our
>> gallery, but I'll try to create one to see if it works.
>>
>> --Mary
>>
>>
>> On Fri, Aug 24, 2018 at 12:06 PM, Fearon, Dr. Matthew, Contractor, Code
>> 7533 via pyngl-talk <pyngl-talk at ucar.edu> wrote:
>>
>>> Just a follow-up. I have learned that fill color between 2 adjacent
>>> lines with Ngl.xy works nicely for an exclusive xy plot. However, it does
>>> not work as an overlay to a contour plot when sfXArray/sfYArray or
>>> sfYCStart/End/ and sfXCStart/End are used in the original contour plot.
>>> Individual xy lines with Ngl.xy can be overlain on a contour plot with no
>>> trouble, but fill color between them does not work.
>>>
>>>
>>>
>>> Any help on this subject would be great.
>>>
>>> Thanks,
>>>
>>> Matt
>>>
>>>
>>>
>>>
>>>
>>> *From:* pyngl-talk [mailto:pyngl-talk-bounces at ucar.edu] *On Behalf Of *Fearon,
>>> Dr. Matthew, Contractor, Code 7533 via pyngl-talk
>>> *Sent:* Thursday, August 23, 2018 12:28 PM
>>> *To:* pyngl-talk at ucar.edu
>>> *Subject:* [pyngl-talk] Fill color between 2 lines with Ngl.xy
>>>
>>>
>>>
>>> Hi, PyNGL Users,
>>>
>>>
>>>
>>> I’m trying to indicate the terrain profile on the attached cross section
>>> plot. I am able overlay an xy line (black, terrain top) and another xy line
>>> (red, ground surface), but am unable to fill color between these two lines.
>>> All the combinations I have tried are not working. Below is my Ngl.xy code
>>> for the overlay. Any help is greatly appreciated.
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Matt
>>>
>>>
>>>
>>> -----
>>>
>>> xvar[100] is a np array of the xvalues
>>>
>>> pter[2,100] is a np array of the yvalues
>>>
>>>
>>>
>>>     xyres                        = Ngl.Resources()
>>>
>>>     xyres.nglFrame               = False
>>>
>>>     xyres.nglDraw                = False
>>>
>>>     xyres.xyLineColors           = ["black","red"]
>>>
>>>     xyres.xyLineThicknesses      = [8,8]
>>>
>>>     xyres.nglXYFillColors        = ["red","red"]
>>>
>>>     xyres.nglXYBelowFillColors   = ["red","red"]
>>>
>>>     xyres.nglXYAboveFillColors   = ["red","red"]
>>>
>>>
>>>
>>>     xyline = Ngl.xy(wks,xvar,pter,xyres)
>>>
>>>
>>>
>>>     Ngl.overlay(plot,xyline)
>>>
>>> _______________________________________________
>>> pyngl-talk mailing list
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/pyngl-talk
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180830/663c000d/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour_and_xy.py
Type: text/x-python-script
Size: 4378 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180830/663c000d/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: contour_and_xy.png
Type: image/png
Size: 124307 bytes
Desc: not available
URL: <http://mailman.ucar.edu/pipermail/pyngl-talk/attachments/20180830/663c000d/attachment-0001.png>


More information about the pyngl-talk mailing list