IncompatibleChartsError(chart_name, chart_positions, plot_positions)
Source¶
Bases: NumdaplotError
Raised when a chart added to a Plot does not have the kind of values of an axis it shares with the Plot.
Its x values are numbers, dates, texts or times of day while the Plot has another kind, or it measures numbers
on an axis of times of day, or the reverse.
Added in version 0.1.0
Parameters:
-
chart_name(str)Name of the chart class added, such as
LineChart. -
chart_positions(str)What the added chart has on the shared axis:
numbers,dates,textsortimes of dayasxvalues, ornumbers on the left axisortimes of day on the left axisas values. -
plot_positions(str)What the Plot has on the shared axis.
Attributes:
-
chart_nameName of the chart class added, such as
LineChart. -
chart_positionsWhat the added chart has on the shared axis:
numbers,dates,textsortimes of dayasxvalues, ornumbers on the left axisortimes of day on the left axisas values. -
plot_positionsWhat the Plot has on the shared axis.
Examples:
from datetime import date
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon"])
days = ndp.Array.from_list([date(2026, 1, 1), date(2026, 1, 2)])
sales = ndp.Array.from_list([120.0, 80.0])
shops = ndp.Table.from_arrays({"city": cities, "day": days, "sales": sales})
plot = ndp.Plot.bar(shops, ndp.BarChart(x="city", y=["sales"]))
line = ndp.LineChart(x="day", y=["sales"])
try:
plot.add_line(shops, line)
except ndp.IncompatibleChartsError as error:
print(error)
# A LineChart with dates cannot be added to a Plot with texts.