BoxChart(columns=None, group_by=None, outliers=Outliers.SHOWN, colors=None)
Source¶
Bases: Chart
Chart summing up the spread of the values of each column as a box, used by Plot.box.
The box goes from the first to the third quartile, with a line at the median. The whiskers reach the furthest values within 1.5 box heights of the box, and the values beyond them are outliers. 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. Times of day are measured on an axis labeled
HH:MM. -
group_by(str | None, default:None)For a Table, a column of texts, categories, booleans or times of day (written
HH:MM) splitting the rows into groups, each drawn at its own position in alphabetical order, with the boxes of the columns side by side. A row whose group is missing is left out. One box per column when omitted. -
outliers(Outliers, default:Outliers.SHOWN) -
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
group_byor a name incolumnsis an empty text. -
EmptyListErrorWhen
columnsorcolorsis an empty list. -
DuplicateColumnErrorWhen a column name appears twice in
columns.
Examples:
import numdaplot as ndp
cities = ndp.Array.from_list(["Paris", "Lyon", "Paris", "Lyon", "Paris", "Lyon", "Paris", "Lyon"])
prices_2025 = ndp.Array.from_list([12.0, 9.5, 14.0, 10.0, 13.5, 8.0, 15.0, 11.0])
prices_2026 = ndp.Array.from_list([14.0, 10.5, 16.0, 11.0, 15.5, 9.0, 17.0, 12.5])
prices = ndp.Table.from_arrays({"city": cities, "2025": prices_2025, "2026": prices_2026})
chart = ndp.BoxChart(columns=["2025", "2026"], group_by="city")
plot = ndp.Plot.box(prices, chart)
plot.show()