[pyngl-talk] color a specific value in NGL

Mary Haley haley at ucar.edu
Thu Oct 26 16:37:27 MDT 2017


I'm sorry for the delay. I didn't realize there was an unanswered question.

When you say "specific value with white color" do you mean that you want to
color a 0-level contour line in white, or that you want to specify a
contour *fill* for values equal to 0?

As an example of specifying a particular color for a contour line, see
spaghetti.py at:


This uses only one contour level, and sets the color for this level using
cnLineColor and an index value:

res.cnLevelSelectionMode = "ExplicitLevels" # explicit contour levels
res.cnLevels             = 5500             # which level(s) to plot
res.cnLineColor          = 1      # index 1 in default color table. Can
                                  # use a named color, like "white"

If you want to set multiple levels with multiple colors, then provide an
array of values to cnLevels, and use cnLineColors to set the color for each.

If you want to set the colors for filling between contour levels, then you
can use cnFillColors. See example hdf3.py, which does this with:

res.cnLevelSelectionMode = "ExplicitLevels"
res.cnLevels             = [0.01,0.02,0.04,0.08,0.16,0.32,0.64, 0.96]
res.cnFillColors         = ["white","cyan", "green","yellow",


On Thu, Oct 19, 2017 at 3:41 AM, Xiaoni Wang <xiaoni.wang at obspm.fr> wrote:

> Hi all,
>      May I ask how to plot a specific value (0 for example) with white
> color by using NGL in a 2D contour plot ? Thank you in advance !
> Best wishes,
> Xiaoni Wang
> _______________________________________________
> 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/20171026/e2273fef/attachment.html>

More information about the pyngl-talk mailing list