[ncl-talk] Hatch over contour plot
Jared Lee
jaredlee at ucar.edu
Thu Mar 8 10:28:05 MST 2018
Hi Marston,
If you're trying to mask your plot with hatching based on data value,
that's fairly straightforward to do using the plotting attribute
cnFillPatterns. See info here:
https://www.ncl.ucar.edu/Document/Graphics/fill_patterns.shtml
https://www.ncl.ucar.edu/Document/Graphics/Images/fillpatterns.png
Here's an example snippet from one my scripts where I use hatching on
contour fill areas below some certain threshold (in this case, temperatures
below 0ºC):
mapres at cnMinLevelValF = -30.0
mapres at cnMaxLevelValF = 40.0
mapres at cnLevelSpacingF = 1.0
n_contours := toint((mapres at cnMaxLevelValF - mapres at cnMinLevelValF
)/mapres at cnLevelSpacingF) + 1
n_contour_levs = n_contours + 1
contour_values := fspan(mapres at cnMinLevelValF, mapres at cnMaxLevelValF,
n_contours)
contour_thresh = 0.0
inds_hatch := ind(contour_values.le.contour_thresh)
mapres at cnMonoFillPattern = False
mapres at cnFillPatterns := new(n_contour_levs, string)
mapres at cnFillPatterns(:) = "Solid"
mapres at cnFillPatterns(inds_hatch) = "CrossHatch_45"
mapres at cnFillScaleF = 0.30
mapres at cnFillMode = "AreaFill"
I hope that helps! Note that cnFillMode *must* be set to "AreaFill" in
order for hatching or stippling to work.
Jared
On Thu, Mar 8, 2018 at 3:47 AM, Marston Ward <marston.johnston at gu.se> wrote:
> Hi,
>
>
> I’m trying to mask a part of a gsn_csm_contour plot using a “hatch”. I
> don’t want to simply mask out the area because I want to the data to still
> be visible under the hatch.
>
> Is it possible to do this in NCL? A simple search returned nothing in NCL.
> Just wondering if this is possible and it so, are there examples.
>
>
> Best,
>
>
> /M
>
> *Marston S. Ward*
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>
>
--
===============================
Jared A. Lee, Ph.D.
Project Scientist I
Research Applications Laboratory
National Center for Atmospheric Research
Boulder, Colorado, USA
Member, AMS Planning Commission
Email: jaredlee at ucar.edu (w)
Phone: 303.497.8485 (w)
Web: https://staff.ucar.edu/users/jaredlee
===============================
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180308/c563fa2f/attachment.html>
More information about the ncl-talk
mailing list