[ncl-talk] Error trying to make a simple pie chart

Rick Brownrigg brownrig at ucar.edu
Tue Sep 1 20:21:54 MDT 2020


Hi Michele,

This does appear to be a bug in the pie_chart function that was introduced
a couple of years ago. You can fix it in your local distribution by editing
the file $NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl:

on both lines 4172 and 4177, replace "colors(n,:)" with "rgba_colors(n:i)".

While I've tested that this works with named colors, colormap indices, and
rgba colors, you should make a backup of shea_util.ncl at least until
satisfied that everything works.

I'll submit a fix to the NCL maintainers.

Hope that helps...
Rick




On Tue, Sep 1, 2020 at 8:45 AM Michele Petrini - CITG via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear helpdesk,
>
> I am contacting you as I am trying to make a simple pie chart and there is
> something strange happening;
>
> when I run this code
>
> color=(/"lightskyblue","brown1"/)
> name=(/"Accumulation","Ablation"/)
> percent=(/10.0,90.0/)
>
> pcRes   = True
> pcRes at gsnMaximize     = True
> pcRes at tiMainString    = areas(i)+": average years "+ystartavg+"-"+yendavg
>   ; Sector Label is default
> piechart    = pie_chart(wks2, percent, name, color, pcRes)
>
> I get the following error:
>
> fatal:Number of subscripts do not match number of dimensions of
> variable,(2) Subscripts used, (1) Subscripts expected
> fatal:["Execute.c":8637]:Execute: Error occurred at or near line 4172 in
> file $NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl
>
> I went to look at line 4172 in shea_util.ncl and what I’m reading is
>
>> 4172      pgRes at gsFillColor   =  colors(n,:)          ; fill with
> associated color
> 4173      plotPC@$*unique_string*("dum")$ = gsn_add_polygon (wks, plotPC,
> xx, yy, pgRes)  ; color fill
> 4174      plotPC@$*unique_string*("dum")$ = gsn_add_polyline(wks, plotPC,
> xx, yy, plRes)  ; outline
> 4175
> 4176      gsRes at gsMarkerColor = colors(n,:)           ; associate marker
>>
> If I replace colors(n,:) with colors(n) in the lines above, the script
> does work fine.
>
> I am still wondering whether there is something wrong in my code -
> although I am using the very same code as in pie_chart_2.ncl (
> https://www.ncl.ucar.edu/Applications/Scripts/pie_chart_2.ncl) - or there
> is a bug in shea_util.ncl.
>
> Thanks!
>
> Michele
>
> ******************************************************************
> Michele Petrini, PhD
>
> Department of Geoscience and Remote Sensing, TUDelft
> Delft, The Netherlands
>
> M.Petrini at tudelft.nl
> +39 3398367372
> michele.petrins (Skype alias)
>
>
>
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at mailman.ucar.edu
> List instructions, subscriber options, unsubscribe:
> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20200901/9d86224e/attachment.html>


More information about the ncl-talk mailing list