Skip to content

ENH: Make bars a primitive and store how histograms were binned - #169

Merged
thclark merged 1 commit into
bars-and-histogramsfrom
bar-primitive
Oct 26, 2026
Merged

thclark merged 1 commit into
bars-and-histogramsfrom
bar-primitive

Conversation

@thclark

@thclark thclark commented Oct 26, 2026

Copy link
Copy Markdown
Owner

This reworks stages 1 and 3 of the bars and histograms epic, following the design review on 2026-10-26.

Bars as a primitive

  • A bar is drawn at its position plus its series' offset. The offset is a multiple of the bar's width, or a distance along the category axis.
  • Its width is a fraction of the pitch, a constant, or one width per bar. It runs from its base to its base plus its value, so each value is a length, as in Matplotlib and Plotly.
  • A margin (default 0.05) extends the automatic value limits beyond the bar ends, so the tallest bar no longer touches the box.
  • Bar groups, slots and gaps are removed from the model, along with the InconsistentBarGroup warning.

The bars helper

The facade's bars helper writes the offsets, widths and bases of grouped columns, stacked columns, and stacks side by side.

Stored bin definitions

  • Bars, stairs and cells gain an optional record of how a histogram was binned: the bins as given, the range, the normalisation, the total and the exclusions.
  • Datatips use the record to report each bin's count and density.
  • Bins, BinRule and HistNorm become model types.

ADRs

The decisions are recorded in four ADRs:

  • 0026: bars are a primitive, coloured as series are.
  • 0027: cells are an artist of their own.
  • 0028: closed shapes have faces and edges, and lines have fills.
  • 0029: histograms store their bins and how they were made.

Existing gallery figures render byte-identically.

Place each bar by its own position, offset, width and base, with its
value as a length from the base and a margin beyond its end in the
automatic limits, and remove bar groups, slots and gaps from the
model. Add the bars helper, which writes the offsets, widths and bases
of grouped and stacked series. Store the bin definition of a histogram
on its bars, stairs or cells so that datatips report each bin's count
and density. Record the decisions in ADRs 0026 to 0029.
@thclark
thclark merged commit d8b8d73 into bars-and-histograms Oct 26, 2026
7 checks passed
thclark added a commit that referenced this pull request Oct 26, 2026
Place each bar by its own position, offset, width and base, with its
value as a length from the base and a margin beyond its end in the
automatic limits, and remove bar groups, slots and gaps from the
model. Add the bars helper, which writes the offsets, widths and bases
of grouped and stacked series. Store the bin definition of a histogram
on its bars, stairs or cells so that datatips report each bin's count
and density. Record the decisions in ADRs 0026 to 0029.
@thclark
thclark deleted the bar-primitive branch October 26, 2026 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant