[ncl-talk] conditional bar chart fill color

Adam Phillips asphilli at ucar.edu
Fri May 4 13:47:23 MDT 2018


Hi Nick,
I think you can apply some of the coding of barchart example #6 to your
situation, especially if every single bar is above the reference line.
http://www.ncl.ucar.edu/Applications/bar.shtml#ex6

I think it's just a matter of setting up an array that has the colors you
want, and then passing that array to gsnAboveYRefLineBarColors.
; xyarr = the array to be plotted
colors = new(dimsizes(xyarr),"string")
colors = "green"
vals = ind(xyarr.ge.1000)

colors(vals) = "blue"
print(xyarr+" "+colors)
res at gsnYRefLine           = 0. ; reference line
res at gsnAboveYRefLineBarColors = colors     ; assigns each bar color
sequentially.

If you have bars both above and below a reference line, you will need to do
something similar to the above but set the bar colors
using gsnXYBarChartColors2 as is shown in the second part of example #6
above.

If you have any further queries please respond to the ncl-talk email list.
Adam

On Thu, May 3, 2018 at 6:04 PM, NB <nbarlow30 at gmail.com> wrote:

> Is there a simple if/else/where/? statement to set *gsnAboveYRefLineColor
> *based on values in an array?
>
> e.g. values above 1000, the color is blue. Else, the color is green.
>
> Thanks.
>
> -nick
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20180504/51db59cc/attachment.html>


More information about the ncl-talk mailing list