[ncl-talk] Error trying to make a simple pie chart
Dennis Shea
shea at ucar.edu
Tue Sep 1 11:10:58 MDT 2020
4172 pgRes at gsFillColor = colors(n,:)
The left hand side is expecting a single value. The error message states:
*(2) Subscripts used*
print(colors(m,:)) ; print contects
Maybe:
pgRes at gsFillColor = colors(n,0) ; 1st color
or
pgRes at gsFillColor = colors(n,1) ; 2nd color
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/a1b52f43/attachment.html>
More information about the ncl-talk
mailing list