HistogramChart(columns=None, bins=None, measure=Measure.COUNT, colors=None)
Source¶
Bases: Chart
Chart drawing how many values of each column fall in each bin, used by Plot.histogram.
Several columns share the same bins and are drawn over each other, half transparent. Missing values are left out.
Added in version 0.1.0
Parameters:
-
columns(list[str] | None, default:None)For a Table, the columns drawn, holding numbers or times of day, not both. A Table needs it, even for a single column. An Array takes none: when omitted, each of its columns is drawn.
-
bins(BinCount | BinWidth | None, default:None) -
measure(Measure, default:Measure.COUNT) -
colors(Sequence[Color | CustomColor] | None, default:None)One color per column, 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 a name in
columnsis an empty text. -
EmptyListErrorWhen
columnsorcolorsis an empty list. -
DuplicateColumnErrorWhen a column name appears twice in
columns.
Examples:
import numdaplot as ndp
prices_2025 = ndp.Array.from_list([12.0, 15.5, 14.0, 17.0, 13.5, 16.0, 14.5, 15.0])
prices_2026 = ndp.Array.from_list([14.0, 17.5, 16.0, 19.0, 15.5, 18.0, 16.5, 17.0])
prices = ndp.Table.from_arrays({"2025": prices_2025, "2026": prices_2026})
chart = ndp.HistogramChart(columns=["2025", "2026"], bins=ndp.BinWidth(1.0))
plot = ndp.Plot.histogram(prices, chart)
plot.show()