Meanmark, fluxbox and hexmatrix
Show observations, summaries and density with individually named plot parts.
Three signature plots are complete plot types unique to Flux. Each takes a table (a pandas or polars DataFrame, or a dict of columns) plus column names, seaborn-style, and names every part for you, so a single mean circle, one subject’s points or one hexagon can be restyled or animated in Flux. The meanmark and the fluxbox show every observation beside a summary of its group and share one set of point, colour and connector controls; the hexmatrix tiles the plane with named hexagons. Hover a real fluxbox on the semantic plots page to see the names.
A complete example (the values are synthetic):
import matplotlib.pyplot as plt
import numpy as np
import fluxplot as fp
fp.use_paper()
rng = np.random.default_rng(1)
table = {
"condition": ["Sleep"] * 8 + ["SD"] * 8,
"subject": [f"m{i}" for i in range(1, 9)] * 2,
"APP/GAPDH": np.r_[rng.normal(1.0, 0.15, 8), rng.normal(1.4, 0.2, 8)],
}
fig, ax = plt.subplots(figsize=(1.8, 2.0), layout="constrained")
mm = fp.meanmark(table, x="condition", y="APP/GAPDH", units="subject", ax=ax)
fp.save(fig, "plots/app_gapdh.svg")In the shorter examples below, df is your table and ax an axes.
Meanmark
# Paired or repeated measures: units= gives every subject a lane and a colour,
# and connects it across conditions.
mm = fp.meanmark(df, x="condition", y="signal", units="subject", ax=ax)
# The summary alone: solid dots, 95 % confidence intervals, caps at the ends.
mm = fp.meanmark(df, x="condition", y="signal", ax=ax,
show_individual_points=False, interval="ci", confidence=.95,
mark_fill_color="stroke", show_caps=True)The meanmark draws the arithmetic mean of each group as an outlined circle with a tinted interior and two uncertainty arms, one below and one above, the compact mean-and-error mark of a scientific figure. Every observation is a dot beside it.
The interval
The default interval is a two-sided 95 % Student-t confidence interval around the mean (interval="ci", confidence=.95, sample SD with ddof=1). The alternatives are:
interval= |
Arms span |
|---|---|
"ci" (default) |
the Student-t confidence interval at confidence |
"sem" |
mean ± SEM |
"sd" |
mean ± SD |
"range" |
the smallest to the largest observation |
a callable values -> (low, high) |
absolute bounds you compute; they must be finite and contain the mean |
Statistics count finite observations and do not collapse repeated rows per unit. A group with one observation has a mean but no estimable SD, SEM or CI: its circle is drawn and its bounds are null. An empty category keeps its tick and has no summary.
orientation="horizontal" turns the plot on its side; x still names the categories and y the values, which are then read along the x axis. value_scale="log" puts the value axis on a log scale while the statistics stay in original units (the arithmetic mean, not the geometric one); non-positive observations or bounds raise an error instead of being clipped.
The mark
Sizes are in points, so they do not change with the axis limits:
- Circle:
mark_size=4.5(diameter),mark_edge_width=1.5. The outline takes the group colour unlessmark_coloroverrides it. - Interior:
mark_fill_color="auto"mixes 25 % of the outline colour into the axes ground (mark_fill_mix=.25), an opaque tint that reads on light and dark grounds alike."stroke"gives a solid dot,"none"a hollow circle, and any Matplotlib colour is accepted.mark_fill_alphaaffects only the interior; the outline stays opaque. - Arms:
error_width=1.7,error_color(defaults to the outline).show_error=Falsehides them. The arms stop at the rim of the circle, so a hollow or translucent circle never shows a line through its centre; an interval shorter than the radius stays inside the circle. - Caps: on by default,
cap_size=3.5long andcap_width=1.2wide;cap_colordefaults to the arms.show_caps=Falseremoves them. - Notch:
show_notch=Truecuts two V-shaped notches into the circle’s outline at the exact mean.notch_depth=1.2andnotch_height=2.0are in points; the depth must be less than the radius and the height less than the diameter. The cutouts are transparent on any ground. - Placement:
mark_offsetis the distance from the category tick in category units; it defaults to.25when points or connectors are shown and to0otherwise.mark_side="right"(default) puts the summary to the right of the points,"left"to the left, and"outer"puts the first group’s summary left and every other right. In a horizontal plot the sides are below and above.mark_offset=0centres every summary on its tick.
Points, units and connectors
With units= every unit (animal, subject, cell) keeps a lane and a colour derived from the table, never from the values, so plots of different measures made from one table agree dot for dot, even when a unit is missing from one of them. Points default to the group colour (point_colors="group") with an area of 13 pt², .06 jitter, .2 pt rims (point_edge="rim") and .45 fill alpha; the rim stays opaque. point_colors="shades" gives every unit its own shade of the group’s map, in equal perceptual steps between shade_range=(88, 22) lightness and dealt across lanes so neighbours contrast (interleave_shades=True).
Connectors join one unit’s points across categories. They default on when units is supplied (connect_identical_points_across_x_values="auto"); False disables them and True requires units. They break at a unit’s missing category rather than bridging it, and default to .5 pt, #5f5f5f and .2 alpha (connect_line_width, connect_color, connect_alpha). connect_color=None takes the theme’s neutral.
These controls are shared with the fluxbox, whose defaults differ (larger, opaque, shaded points and no connectors unless asked):
show_individual_points,point_size(points²),jitter,point_edge,point_edge_width,point_fill_alpha;palette,group_color,group_color_position,point_colors,shade_range,interleave_shades. A palette is anyfp.colors.mapscolormap ("cmasher.emerald"), anyfp.colors.palettespalette ("brewer.Set2","tol.bright"), a Matplotlib map, a list of colours or one colour; a mapping chooses a palette per category. The defaults cycle through ColorBrewer’sYlGnBu,YlOrRd,RdPu,BuGn,PurplesandYlOrBr. See Colour and style for pinned category colours;connect_identical_points_across_x_values,connect_line_width,connect_color,connect_alpha;order,unit_order,series,unit_series,label_axes,zorder.
Set the shared controls explicitly when you want a meanmark and a fluxbox of the same table to use identical point styling.
Named parts and statistics
| Part | Role | Default ID |
|---|---|---|
| mean circle, including its notched outline | mean (a shape: fill and stroke editable) |
<category>.mean |
| lower uncertainty arm | errorbar |
<category>.error-low |
| upper uncertainty arm | errorbar |
<category>.error-high |
| lower and upper caps | cap |
<category>.cap-low, <category>.cap-high |
| a unit’s points | point |
<unit>.points, <unit>.point.<k> |
| a unit’s connector | line |
<unit>.line |
points without units |
point |
<category>.points, <category>.point.<k> |
IDs persist when caps, points or notches are toggled, and lower and upper always refer to data values, including on an inverted axis. Each category series carries a meanmark manifest payload with the exact statistics drawn (n, mean, meanKind, sd, sem, interval, confidence, low, high, x, y, categoryPosition, orientation, scale, groupColor, palette), and each unit series its identity; the manifest’s plotType is "meanmark". Series names default to the category and unit values; series= and unit_series= (a mapping or a callable) rename them. flux get-plot-data returns these statistics, and the circle, each arm and each cap are separate components that Flux can restyle one by one.
The call returns a MeanmarkResult with .ax, .categories, .stats (category → the payload above), .group_colors, .point_colors, .series, .unit_series, .orientation and .artists (mean, error_low, error_high, cap_low, cap_high, points, lines). A vertical plot also offers .positions and .brackets(rows), which draws fp.stats rows as stacked significance brackets over the categories; see Statistics and comparison brackets. The fluxplot repository’s examples/meanmark_example.py draws a paired plot with recipe parameters and a sheet of the summary styles (tinted, solid, hollow, notched, horizontal, dark ground).
If you used glowbar
Earlier releases drew this summary as a glowbar, a bar that faded away from the mean with a median notch. fluxplot 0.4 replaces fp.glowbar with fp.meanmark; the old name is gone. The table call is the same (data, x, y, units, ax), as are the point, colour, connector and naming keywords. What changed: the default interval is the 95 % confidence interval rather than ± SEM; there is no median mark (use a fluxbox for medians); the bar controls (bar_*, glow_*, mean_line_width, mean_halo_width, median_*) became the mark_*, error_*, cap_* and notch_* controls above; and the part IDs <category>.glow, .caps and .median became .mean, .error-low, .error-high, .cap-low and .cap-high. Regenerate a glowbar plot with the new call; restyles saved against the old IDs do not carry over.
Fluxbox
The fluxbox uses a box plot for its summary. It is the same call with the same lanes, colours, connectors and names as the meanmark:
fb = fp.fluxbox(df, x="condition", y="APP/GAPDH", units="subject", ax=ax)
# Paired: the same mice before and after.
fb = fp.fluxbox(df, x="condition", y="APP (% of C)", units="mouse", ax=ax,
connect_identical_points_across_x_values=True)Beside each group sits a slim box (Q1–Q3), a half-strength wash of the group colour (box_alpha=0.5). The median is a solid line across it in the group’s own hue, deepened (or, on a dark ground, lifted) only as far as it takes to differ from the box by median_contrast=30 units of perceived lightness, so it reads for any palette and theme; the whiskers and fliers share that ink, so the box is the only wash. The mean is a V-notch cut into both edges of the box. The notch is a true gap in the box’s outline, not paint: the ground, and anything drawn behind the box, shows through it, and the median line is trimmed to the notched outline where the two meet. A mean outside the box (a strongly skewed group) keeps its mark as the same two V’s drawn solid in the ink, pointing in at the whisker. The capless whiskers reach the most extreme observations within whis × IQR of the box (1.5, Tukey’s rule, exactly plt.boxplot’s whiskers), "range", or a (low, high) pair of percentiles. Observations beyond the whiskers are not drawn again as fliers, because the points already show them, unless the points are hidden (show_fliers="auto").
On a log y axis (yscale="log", or an axes that is already log-scaled) every statistic is taken in log space and drawn back on the data scale: the quartiles and median are unchanged, the mean notch marks the geometric mean (meanKind: "geometric" in the manifest), and Tukey’s whisker reach is a factor of the IQR in log units, so the box reads the way the axis does. Non-positive values cannot sit on such an axis and are left out.
| Part | Role | Default ID |
|---|---|---|
| box (Q1–Q3) | box |
<category>.box |
| whiskers | whisker |
<category>.whiskers |
whisker caps (show_caps=True) |
cap |
<category>.caps |
| median line | median |
<category>.median |
| mean notch | mean |
<category>.mean |
| fliers (points hidden) | flier |
<category>.fliers |
| points and connectors | point, line |
as for the meanmark |
Each category series carries a fluxbox manifest payload with the exact statistics drawn (n, mean, median, sd, sem, q1, q3, iqr, whis, whiskerLow, whiskerHigh, outliers, x, groupColor; on a log axis also scale and meanKind); the manifest’s plotType is "fluxbox".
The box keywords are whis, yscale, box_width, box_alpha, box_offset, box_side ("outer", the default, puts the first category’s box left of its points and every other right), median_line_width, median_color (sets the median colour outright), median_contrast, mean_notch_depth, mean_notch_height, whisker_width, whisker_color, cap_size, cap_width, cap_color, flier_size, cut_color (the ground the median’s contrast is judged against; the notch itself takes no colour), and the switches show_mean, show_median, show_whiskers, show_caps and show_fliers. The point, colour, connector and naming keywords are the shared controls above; the fluxbox defaults are point_size=18, jitter=0.14, point_edge_width=0.5, opaque points, point_colors="auto" (shades with units, else the group colour) and connectors off. It returns a FluxboxResult with the same core fields as a MeanmarkResult (without orientation), including .positions and .brackets(rows). The fluxplot repository’s examples/fluxbox_example.py draws both designs shown above.
Hexmatrix
The hexmatrix tiles the plane with regular hexagons, each one a named part. One call covers a point cloud’s density, a 2D gradient of a third variable, and a matrix drawn on a hex lattice:
# Density with marginal histograms, jointplot-style:
hm = fp.hexmatrix(df, x="x", y="y", ax=ax, color="#4CB391", marginals=True)
# Log-log density with an identity line:
hm = fp.hexmatrix(df, x="wake", y="nrem", ax=ax, xscale="log", yscale="log",
norm="log", identity_line=True,
colorbar_label="Synapses per hexbin")
# Spatial density in 0.15 mm bins:
hm = fp.hexmatrix(df, x="ccf_x", y="ccf_z", ax=ax, aspect="equal", binwidth=0.15,
norm="log", colorbar_label="somata / hexbin")
# A gradient of a third variable, C:
hm = fp.hexmatrix(df, x="x", y="y", C="rate", reduce="median", ax=ax,
cmap="RdBu_r", center=0)
# A matrix drawn on a hex lattice:
hm = fp.hexmatrix(matrix=weights, ax=ax, gap=0.08)Hexagons are addressed by their lattice position: row counts up the y axis and col along x, so <series>.hex.<row>.<col> names the same hexagon in every plot with the same extent and grid, whatever the data. They are regular on the page. aspect="auto" locks the axes’ box aspect so a later layout pass can’t squash them, and aspect="equal" bins in true data units. Log axes bin in log space.
The colour can be a count, stat="density"/"probability"/"percent" (optionally weights=), or a reduce of C (mean, median, sum, min, max, std, count or a callable). The scale is set by cmap/color (a single-hue ramp), norm (linear/log/sqrt or any Normalize), vmin/vmax, robust and center. Further keywords:
mincnt=0draws the empty hexagons too;sparse=kdraws points instead of hexagons where fewer thankobservations fall;show_pointsoverlays every observation;gap,edgecolor,linewidthandorientation="flat"shape the hexagons;marginals,colorbarandidentity_lineadd furniture;alpha_byadds an opacity channel (see Value × confidence).
The colormap and colour limits are recipe controls, exactly as for fp.heatmap: Flux’s Colour scales editor can change them and regenerate the plot.
| Part | Role | Default ID |
|---|---|---|
| all hexagons | x-hexbin |
<series>.hexes |
| one hexagon | x-hex |
<series>.hex.<row>.<col> |
| sparse or overlaid points | point |
<series>-points.points, <series>-points.point.<k> |
| identity line | reference-line |
reference-line.identity |
| marginal histograms (own panels) | bar |
<series>-x.bar.<k>, <series>-y.bar.<k> |
Each hexagon element also carries data-row, data-column, data-x, data-y, data-count and data-value attributes.
The series carries a hexmatrix manifest payload: the lattice (orientation, radius, aspect, scales, extent), the statistic, and every hexagon drawn (row, col, x, y, count, value). It also carries the usual field colour payload; the plotType is "hexmatrix". The call returns a HexMatrixResult (.ax, .hexes, .bins, .cmap, .norm, .colorbar, .marginal_axes, .points, .hex_id(row, col), .lookup(x, y)).
Hexagons stay individually addressable up to vector_limit (5000 by default; None uses the save’s generic threshold of 800 elements). A larger layer is rasterized like any heavy layer, but its hexagons stay in the manifest; pass force_vectors=True to fp.save to keep every hexagon addressable. On axes that share x or y with other panels, fp.hexmatrix leaves the box aspect unlocked, with a warning, rather than distorting the sibling panels. The fluxplot repository’s examples/hexmatrix_example.py draws all five variants shown above.
Every parameter of the three plots is listed in the Python API reference (fluxbox, hexmatrix).