[ncl-talk] using ColorNegDashZeroPosContour
Cathy Smith
cathy.smith at noaa.gov
Fri Jan 12 11:22:09 MST 2018
Thanks. That will work for me.
Cathy
On 1/12/18 10:53 AM, Rick Brownrigg wrote:
> Hi Cathy,
>
> I spent some time looking around for some other means, but couldn't
> find one that was short of programmatically constructing everything
> oneself. However, the function ColorNegDashZeroPosContour, contributed
> by Adam Phillips, is pretty straightforward and relatively short --
> you can easily modify it. I've appended it below, and commented out
> the line that forces the dash pattern (also colored in red) -- you
> could "load" this custom version for your own needs.
>
> Rick
>
> ;************************************************************************
> ; Adam Phillips
> ;
> ; Set neg contour lines to dash and draw with the color cneg,
> ; draw positive contours with the color cpos, and draw the zero line with
> ; the color czero.
>
> ; Usage: plot= ColorNegDashZeroPosContour(plot,"blue","black","red")
> ;
> ;
> undef("ColorNegDashZeroPosContour")
> function
> ColorNegDashZeroPosContour(plot:graphic,cneg:string,czero:string,\
> cpos:string)
>
> local cnlvls, cnlinepat, n, N, cncolor
> begin
>
> cnlvls = get_cnLevels (plot)
>
> N = dimsizes(cnlvls)
> if (ismissing(N) .or. N.le.0) then
> print ("NegDashLineContour: dimsizes(cnlvls)="+N+" return
> (non-fatal)")
> return (plot)
> else
> cnlvls = FixZeroContour (cnlvls, "NegDashLineContour")
> end if
>
> if (any(cnlvls.lt.0.)) then
> cnlinepat = new (dimsizes(cnlvls), integer) ; create array for
> line pats
> cnlinepat = 0 ; default is solid (=0)
> cncolor = new (dimsizes(cnlvls), string) ; create array for
> line colors
> cncolor = cpos ; default is black
> do p=0,dimsizes(cnlvls)-1
> if (cnlvls(p).lt.-1.e-05) then
> ; ; cnlinepat(p) = 1 ; simple dash line
> pattern
> cncolor(p) = cneg
> end if
> if (cnlvls(p).ge.-1.e-05.and.cnlvls(p).le.1.e-05) then
> cncolor(p) = czero
> end if
> end do
>
> ovrly_plot = GetOverlayPlot (plot, "contourPlotClass", 0)
> setvalues ovrly_plot
> "cnMonoLineDashPattern" : False
> "cnLineDashPatterns" : cnlinepat
> "cnMonoLineColor" : False
> "cnLineColors" : cncolor
> end setvalues
> end if ; any
> return (plot)
> end
>
>
>
>
>
> On Fri, Jan 12, 2018 at 9:56 AM, Cathy Smith via ncl-talk
> <ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>> wrote:
>
> Hi all:
>
> I am using ColorNegDashZeroPosContour as in
>
> plot = ColorNegDashZeroPosContour(plot,"red","magenta","blue")
>
> This works great except I would like the negative lines not
> dashed. I tried setting the resource dashline type to solid and
> when I checked the res, it is set that way e.g.
>
> gsnContourNegLineDashPattern : 0
>
> Is it possible to do what I want with ColorNegDashZeroPosContour? Or is there another routine I should try? Or do I need to hand code this? I have
>
> res at gsnContourNegLineDashPattern = 0 ; sets negative contours to dash pattern 1
> plot = gsn_csm_contour_map_ce (wks, mapx({lat1:lat2},{lon1:lon2}), res) ; create ;temporary plot
> plot = ColorNegDashZeroPosContour(plot,"red","magenta","blue")
> print(res)
> draw(plot)
> frame(wks)
>
> Thanks!
> Cathy
>
> --
> ----------------------------------------------
> NOAA/ESRL PSD and CU CIRES
> 303-497-6263 <tel:%28303%29%20497-6263>
> http://www.esrl.noaa.gov/psd/people/cathy.smith/
> <http://www.esrl.noaa.gov/psd/people/cathy.smith/>
>
> Emails about data/webpages may get quicker responses from emailing
> esrl.psd.data at noaa.gov <mailto:esrl.psd.data at noaa.gov>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu <mailto:ncl-talk at ucar.edu>
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
> <http://mailman.ucar.edu/mailman/listinfo/ncl-talk>
>
>
--
----------------------------------------------
NOAA/ESRL PSD and CU CIRES
303-497-6263
http://www.esrl.noaa.gov/psd/people/cathy.smith/
Emails about data/webpages may get quicker responses from emailing
esrl.psd.data at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180112/0ccfcbae/attachment.html>
More information about the ncl-talk
mailing list