histplot¶
histplot(data, *, x=None, y=None, hue=None, hue_order=None, stat='count', bins=10, binwidth=None, binrange=None, discrete=False, color=None, palette=None)
¶
Plot a histogram of a numeric variable.
Bins must be equal-width — Mermaid places bars equidistantly, so unequal bin widths would misrepresent the data and are rejected.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
IntoFrame
|
Input data. Any narwhals-compatible DataFrame or LazyFrame. |
required |
x
|
str | None
|
Column name for horizontal distribution (mutually exclusive with |
None
|
y
|
str | None
|
Column name for vertical distribution (mutually exclusive with |
None
|
hue
|
str | None
|
Column name for grouping into separate series. |
None
|
hue_order
|
list | None
|
Explicit order for hue levels. |
None
|
stat
|
str
|
Statistic to plot. One of |
'count'
|
bins
|
int | list
|
Number of equal-width bins, or an explicit list of bin edges. |
10
|
binwidth
|
float | None
|
Width of each bin. Overrides |
None
|
binrange
|
tuple | None
|
|
None
|
discrete
|
bool
|
If |
False
|
color
|
str | None
|
Single colour for all bars (CSS colour string). |
None
|
palette
|
list | None
|
List of colours, one per hue level. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
XYChart |
XYChart
|
An instance ready to render or further configure. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If neither or both of |