PieChart(labels, values, percentages=Percentages.SHOWN, colors=None)
Source¶
Bases: Chart
Chart drawing each row of a Table as a slice of a disc, sized by its share of the total, used by Plot.pie.
The slices start at the top and follow each other clockwise, in the order of the rows, each labeled with
its text. Every value must be present and positive or 0, and every label must be different. Beyond 5 slices,
a ReadabilityWarning suggests a BarChart.
Added in version 0.1.0
Parameters:
-
labels(str)The column of texts, booleans or times of day (written
HH:MM) naming the slices. -
values(str)The column of numbers sizing the slices.
-
percentages(Percentages, default:Percentages.SHOWN)Whether each slice shows its share, such as
42.5%,Percentages.SHOWNby default. -
colors(Sequence[Color | CustomColor] | None, default:None)One color per slice, the colors of the default cycle when omitted. The chart keeps its own list.
Raises:
-
InvalidTypeErrorWhen a setting is not of the type its annotation names.
-
InvalidColumnNameErrorWhen
labelsorvaluesis an empty text. -
EmptyListErrorWhen
colorsis an empty list.
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon", "Pau"])
sales = ndp.Array.from_list([120.0, 80.0, 45.0])
shares = ndp.Table.from_arrays({"city": cities, "sales": sales})
chart = ndp.PieChart(labels="city", values="sales")
plot = ndp.Plot.pie(shares, chart)
plot.show()