[ncl-talk] gsnXYBarChartColors request

Alan Brammer abrammer at albany.edu
Fri Aug 21 15:59:30 MDT 2015


Follow up:
I found the better solution while delving around in some of the newer
functions.
rgba_to_color_index
<https://www.ncl.ucar.edu/Document/Functions/Built-in/rgba_to_color_index.shtml>

my very simple example:
y := (/ 17., 16., 20., 21., 4./)
x := (/0,1,2,3,4/)
colors := rgba_to_color_index(  (/
(/0.972549,0,0/),(/0.533333,0.25098,0.12549/),(/0,0,0.972549/),(/0.972549,0.470588,0/),(/0.972549,0,0.972549/)
/)  )
bars := True
bars at gsnXYBarChart = True
bars at trYMinF = 0.
bars at gsnXYBarChartColors = colors
plot = gsn_csm_xy(wks,x, y, bars)


On Mon, Aug 17, 2015 at 5:32 PM, Alan Brammer <abrammer at albany.edu> wrote:

> Hi Rick,
>
> No problem.  I see the difficulty there.
> This was the work around I came up with.  Which is more than fine, just
> haven't had to define a colormap in a while.
>
>
> y := (/ 17., 16., 20., 21., 4./)
> x := (/0,1,2,3,4/)
> colors := (/
> (/0.972549,0,0/),(/0.533333,0.25098,0.12549/),(/0,0,0.972549/),(/0.972549,0.470588,0/),(/0.972549,0,0.972549/)
> /)
>
> *gsn_define_colormap(wks, array_append_record( (/
> (/1.,1.,1./),(/0.,0.,0./)/),colors,0) )  ;; need a back/foreground color to
> start*
>
> bars := True
> bars at gsnXYBarChart = True
> bars at trYMinF = 0.
> *bars at gsnXYBarChartColors := ispan(2,dimsizes(y)+1,1) ;; This would cause
> a problem if you don't have enough colors*
> plot = gsn_csm_xy(wks,x, y, bars)
>
>
> Alan.
>
>
> On Mon, Aug 17, 2015 at 5:21 PM, Rick Brownrigg <brownrig at ucar.edu> wrote:
>
>> Hi Alan,
>>
>> Yes, I see what you mean here.  There is ambiguity on how to interpret
>> the dimensionality of the colors array -- should it be construed as RGBa
>> color-specs, or is it an array-of-arrays of colors for multiple y-curves?
>> I'll file a ticket on this one.
>>
>> I unfortunately don't have a good work-around for you... :-/
>>
>> Rick
>>
>> On Mon, Aug 17, 2015 at 12:21 PM, Alan Brammer <abrammer at albany.edu>
>> wrote:
>>
>>> ​If it's not already in the pipeline, can rgba functionality be added to
>>> gsnXYBarChartColors at some point.   In the intermediate time, it could be
>>> helpful to add to the documentation that it's colormap or named colors only
>>> at this point.  I just went back and forth trying to make this work and
>>> failing with no obvious reason.
>>>
>>> I may be doing something wrong here, but I couldn't make it work.
>>>
>>>
>>> Alan.
>>>
>>>
>>> test script:
>>> y := (/ 17., 16., 20., 21., 4./)
>>> x := (/0,1,2,3,4/)
>>> colors := (/
>>> (/0.972549,0,0/),(/0.533333,0.25098,0.12549/),(/0,0,0.972549/),(/0.972549,0.470588,0/),(/0.972549,0,0.972549/)
>>> /)
>>> bars := True
>>> bars at gsnXYBarChart = True
>>> bars at trYMinF = 0.
>>> bars at gsnXYBarChartColors := colors
>>> plot = gsn_csm_xy(wks,x, y, bars)
>>>
>>>
>>>
>>>>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20150821/1b09a6f0/attachment.html 


More information about the ncl-talk mailing list