EmptyTotalError(chart_name, column_name)
Source¶
Bases: NumdaplotError
Raised when the values of a PieChart add up to 0, which leaves nothing to share out.
Added in version 0.1.0
Parameters:
-
chart_name(str)Name of the chart class, such as
PieChart. -
column_name(str)The column of the values.
Attributes:
-
chart_nameName of the chart class, such as
PieChart. -
column_nameThe column of the values.
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon"])
sales = ndp.Array.from_list([0.0, 0.0])
shares = ndp.Table.from_arrays({"city": cities, "sales": sales})
chart = ndp.PieChart(labels="city", values="sales")
try:
ndp.Plot.pie(shares, chart)
except ndp.EmptyTotalError as error:
print(error)
# PieChart needs a positive total, the values of 'sales' add up to 0.