Skip to content

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)

    The bins, BinCount(10) for numbers and one bin per hour from 00:00 to 24:00 for times of day when omitted, or BinWidth for bins of a given width: a number for numbers, a duration for times of day.

  • measure (Measure, default: Measure.COUNT)

    Measure.COUNT by default for the number of values of each bin, Measure.RATIO for their share of the values of the column.

  • 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:

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()

Plot drawn by the example