Repository navigation
Colour and categories: the colour axis, bins, shapes, edges, hatching, grouped bars, contour labels - #59
Merged
Conversation
A panel gains `ColorAxis`, the record its x and y axes already are. Its kind is the norm every continuous colour channel on the panel maps through (`withColorLog`, `withColorSymlog`, `withColorPower`, `withColorScaleKind`), applied when the figure is prepared and so before a shot unions its colour domains; a channel added later is drawn on it too. A log norm over data holding zero takes its domain over the values it can place. Its ticks, format, prefix, minor ticks, label and look are the colorbar's (`withColorTicksAt`/`Every`/`Named`, `withColorTickFormat`, `withColorPrefix`, `withColorMinorTicks`, `withColorLook`), from F# in both modes and from C#. A stated tick in another dimension is refused at the call with both units named. `AxisHidden` draws no bar and gives its column back to the plot. A symlog scale is ticked at 0 and at the powers of its base past the threshold, on both sides, thinned evenly, and written as signed powers of ten with no prefix (D252). It had linear ticks, which labelled only the outermost decade. Gate 1 (norms, D251, D252) in ColorAxisTests, each made to fail once by its break: the colour kind skipped in prepare (five norm tests fail), and symlog's linear tick hint restored (both symlog tests fail). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A value a colour channel's scale gives no finite position is not drawn and is counted as unmapped, as a NaN is (D267): a log norm painted 0 and -1 K in its low end colour. The test is on the projection, so it holds for every kind. A stated colour domain with an end the norm cannot place is refused at the call, naming the kind. A channel's `Outside` is `Clamp` (the end colour, the default) or `Drop` (not drawn, counted), set by `withColorOutside`, on marks and on a field's pixels (D268). `withColorCentre` moves a ramp's middle to a value, applied once the domain is final, so a neutral colour stays on 0 K across a shot whose domain grows; the bar stays linear (D253). `withColorSymmetric` widens the domain about the centre instead. A centre outside the domain is refused with the domain named. A panel's `Colorbar` record holds `Extend`. `ColorExtend.Auto` draws a triangle at an end whose bound clips data drawn in the end colour, over a shot's union of states, so a triangle does not blink; `Neither`, `Min`, `Max` and `Both` state it (D255). A bar without triangles compiles as before. The guide's dipole and cylinder-wake figures gain theirs. Gates 2, 2b and 4, each made to fail once by its break: the centre applied before the shot's union (the first frame's zero leaves the neutral), the bucketer testing the value instead of its projection (the log test draws a zero), and the extent evaluated per frame (the first frame draws no triangle). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`ChannelMap.ColorByBins` (D254) colours a value by the bin it falls in between stated edges, found by binary search: a value on an edge is in the bin above it, one past either end in the end bin (or dropped under `Drop`, and then not drawn). `withColorBins` bins the last layer's colour channel, its colours sampled from the ramp at each bin's middle along the bar through the continuous quantiser, so a bin and a continuous mark at its midpoint are one colour; `withColorBinsColored` states them. Both in either mode and from C#. The bar draws one strip per bin. `ColorbarConfig.Spacing` is `Uniform` (every bin one length, the default) or `Proportional` (`withColorbarProportional`); the ticks stand at the edges unless stated, moved with the spacing. A clamped value past the edges gives the bar its triangle, in the end bin's colour. `Field.bands` bins its own levels, so its bar is one strip per band ticked at the levels rather than a ramp: `figure-field-bands.tex` moves (a Changed entry). The two field tests that compare a band with a pixel at its midpoint pass unchanged. Gate 3, made to fail once by its break: bucketing through the 256-step quantiser along the bar puts 0.99 in the bin from 1 to 2. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Within a panel, continuous colour channels are one scale (D256): the first one's mapping over the union of their domains, values converted into its unit; two dimensions are refused when drawn, naming both units and both layers. Only the first was keyed before, silently. `Chart.shareColor` records a colour share group (`Panel.ColorShare`, as `shareX` records its own; renumbered by composition) after checking one dimension at the call. A group of two or more panels takes one scale and draws one bar in a figure-level track beside (or below) the group, along its plots once they are lined up. A stated domain on one member is stated on all. A facet records it. `ColorbarConfig` gains `Placement` (`ColorbarRight`, `ColorbarBelow`, `ColorbarNone`; open), `Length` and `Thickness` (D257, D258): `withColorbarBelow`, `withColorbarLength`, and `withColorbar` for the rest. A bar below takes two zero-by-default rows under the x title, so no baseline moves. Gate 5, made to fail once by each break: dropping the group in prepare (two bars, four tests fail) and placing the shared bar from its grid cell rather than the plots (the span tests fail). The suite (2145), the Fable gate (40 of 40 SVG, canvas and wire goldens under Node) and the API listing (adds only) are green. This is the plan's cut line. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`Palette.inferno` and `Palette.plasma` complete the viridis family, ten stops from the published CC0 tables as the others are. `Palette.redBlue` is ColorBrewer's eleven-class RdBu (Apache 2.0) and `Palette.coolWarm` Moreland's cool-warm (public domain); both are named in the new THIRD-PARTY-NOTICES.md. `Palette.cyclic` is Marey's own, built in Oklab (D259): light at both ends, darkest at the middle, lightness falling as half a cosine so it turns smoothly at the wrap, chroma zero where the hue changes side. `Palette.isCyclic` checks the ends agree to 0.002. Gate 6: every sequential ramp passes the lightness test, and an inferno with a stop that turns back fails it. The plan's ΔL 0.01 for diverging symmetry does not hold for the quoted tables (RdBu's ends differ by 0.014, cool-warm's arms by up to 0.012), so the test allows 0.015 and says why; the data is quoted, not adjusted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`MarkerShape` gains `MarkStar`, `MarkPentagon`, `MarkHexagon`, `MarkTriangleLeft`, `MarkTriangleRight`, `MarkVLine` and `MarkHLine` (D264), their outlines computed once in Core's `MarkerOutline`, vertices on the mark's circle, the bars a plus's arms. SVG, TikZ, Skia and the canvas draw from that table; the GPU and WebGL shaders have a signed distance each: regular polygons by their edges' half-planes, the bars as boxes, and the star as five convex pieces (a point with the inner pentagon), which overlap inside so no outline is drawn where they meet. A star's instance quad reaches its 36-degree miter. On the wire the new shapes are bytes 7 to 13 and need format version 2 (`Wire.Version` is 2); a scene without them is still written as version 1, byte for byte, so no wire golden moves. `GeomStyle` gains `Edge`, `EdgeWidth` and `Hollow` (D265): `withEdge` outlines every filled mark in a colour with its own colour as fill, and `withHollow` drops the fill. Legend swatches follow. Unset, every mark is drawn as before. `hollowByKey` is not built: splitting a layer by level enumerated each level twice in the legend; it waits for a better spelling. Gate 7: each new shape's ink in Skia's raster is its outline's box to a couple of pixels; the GPU agrees with the CPU raster for all fourteen, outlined and overlapping, at 1x and scaled; all fourteen survive the wire, and the version is the one the scene needs; white bars with a black edge show their edge and their swatch's. Breaks: stroking the edge in the mark's colour and writing the star as byte 0 each fail their test. The case-count and newer-version wire tests move to 14 and 3. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`GeomBarOn` (D261, an open `Geom` case) draws bars each from a baseline of its own, as wide as a width stated in the x axis's numbers (a band is 1 on a categorical axis), so a stacked part starts where the one below it ends and a grouped bar keeps its width whatever keys its group has. `Chart.Category.barsBy` (D260) puts a bar per (key, group) side by side in the key's band, one layer, one legend entry and one colour per group; a missing (key, group) leaves its slot empty. `addErrorbarsBy` puts error bars on the same slots. `Chart.Category.stackedBy` stacks the groups' parts in group order, negative parts down from zero apart from positive ones, the y axis reaching the tallest stack and the legend reading top-down. `Chart.stackArea` does the same for areas over one x. `Chart.horizontal` (D262) lays a panel on its side; each axis already keeps the title of the quantity it reads, so no title fix was needed (the K5 `x [m]` is the length's symbol, the same upright). `addBarLabels` (D269) writes each bar's height by it in the text colour, above a rising bar and below a falling one. All in both modes and from C#. Gate 8, each made to fail by its break: slots taken from the groups present at a key move Ge's bar; a stack's domain from its parts, not its sums, clips the top. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A `Hatch` (D263) is a pattern (`HatchPattern.Diagonal`, `BackDiagonal`, `Cross`, `Horizontal`, `Vertical`, `Dots`; an open union), a spacing and a line width in device px, and an optional colour (else the mark's edge, else its fill darkened halfway to black). `GeomStyle.Hatch` puts one on every filled mark: the compiler draws the fill, then the hatch's lines under a `Clip` of the mark's outline, then the outline, so every backend draws it as it is and none chooses a pattern phase of its own. The lines are anchored to the plot's corner, so a stack's parts' lines meet across their seam. `withHatch` sets it; `hatchByKey` maps levels to hatches through `ChannelMap.HatchByLevel`, cycling `Theme.Hatches`, empty in every built-in theme (which then cycles `Hatch.cycle`), so no golden moves. Legend swatches are hatched. Both from C#. Gate 9: hatched bars and their swatch are clipped lines in the scene, the SVG and the TikZ; in Skia's raster no hatch ink falls outside the bars; a stack's two parts are on one family of lines. Break: anchoring each mark's hatch to its own box offsets the upper part's lines, and the test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`FieldMark.FieldContoursLabelled` (D266, an open `FieldMark` case) draws contour lines with a label on each line long enough to carry one: on its straightest stretch (least turning over the label's length, ties to the earliest), rotated along it and kept upright, clear of the plot's edge and of every label placed before it. Then every line, of any level, is cut where it passes under a label's box, plus a gap. All of it is arithmetic in device px, so a figure labels itself the same everywhere. `Field.withContourLabels` (typed with the values' witness, and `Field.WithContourLabels(valueUnit = …)`) writes each level as an axis over the levels would, in that axis's prefix and with its unit: `5 mm`, `20 mm`. `withContourLabelFormat` writes the numbers another way in the same unit. Both from C#. Gate 10: the levels are written in millimetres; no two labels closer than their widths; no contour sampled inside a label's box; labels upright and inside the plot; a stated format applied. Break: skipping the cut runs the lines through the labels, and the test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Six new baselines, each as SVG, TikZ (compiled), canvas log and wire, and byte-identical under Node: `figure-color-norms` (two panels, one symlog bar), `figure-color-centre` (a centred ramp, its bar below with triangles), `figure-color-bins` (bands and binned stations, one bar), `figure-markers` (fourteen shapes, filled, hollow and edged), `figure-bars` (grouped bars with errors and hatching beside stacked horizontal ones) and `figure-contour-labels`. Their fields are made of arithmetic only, and a contour label's rotation is rounded to a nanoradian, because .NET and JavaScript round `exp` and `atan2` differently in the last bit and the wire carries every bit. The colour axis's and the colorbar's verbs, and a colour centre, act on the whole colour share group when the last panel is in one, as a stated domain does: the group draws one bar, from its first panel's settings. `Hatch.Of` spells a hatch from C#. The guide gains "The colour axis" (§5) and "Groups, stacks, edges and hatching" (§3), with two new figures, and a C# block of grouped bars (§14), run by the C# suite. `examples/bandgaps.fsx` draws grouped, hatched bars beside a stacked budget. The changelog's Unreleased lists what was added and the drawings that changed; `docs/not-in-1.0.md` loses its colour and marks items. The page script is rebuilt. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The outline table's doc comment named a milestone, which the internal-references check refuses in what ships. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… into colour and categories Both sides added to the same places: the changelog's Added list, the tick and label cases of each scale kind, the last-layer verbs, the golden scene lists and the C# guide, which now has five blocks. Stated ticks keep their module-level home and pass a calendar spec through. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Colour and categories, the first 1.x minor: the colour channel becomes a third axis of its panel, and filled marks gain the edges, hatches and shapes a greyscale paper figure needs. Additive throughout;
api/only gains lines, apart fromWire.Versiongoing from 1 to 2.What it adds
Panel.ColorAxis): a norm (withColorLog,withColorSymlog,withColorPower), stated ticks, format, prefix, minor ticks and look for the colorbar.withColorCentreputs a diverging ramp's neutral on a value without stretching the bar;withColorSymmetricwidens the domain about it;withColorOutside Dropleaves out-of-domain values undrawn.withColorBins,ChannelMap.ColorByBins), exact, one strip per bin on the bar, uniform or proportional. Field bands are bins.Panel.Colorbar): below the plot, a length, a thickness, end triangles (derived from clipped data, stable across a shot).Chart.shareColorgives several panels one scale and one bar; a facet shares its colour scale.THIRD-PARTY-NOTICES.md.withEdge,withHollow,withHatch,hatchByKey), with legend swatches to match.Category.barsBy(withaddErrorbarsBy),Category.stackedBy,stackArea,horizontal,addBarLabels, through a new openGeomcase,GeomBarOn.Field.withContourLabels), in the levels' unit and prefix (5 mm), the lines cut under them.All of it in both F# modes and from C#.
What it changes in drawings
dipole.svgandcylinder-wake.svgmove.figure-field-bands.texmoves.figure-color-norms,-centre,-bins,figure-markers,figure-bars,figure-contour-labels, each SVG, TikZ, canvas log and wire, byte-identical under Node.Verified
Each gate in
tests/Marey.Tests/ColorAxisTests.fs(75 tests) was made to fail once by the break the plan names beside it, and then passed. Locally: the .NET suite (2181), the C# suite (39), the Fable gate (46 of 46 SVG, canvas and wire goldens under Node), the API listing and the undocumented check, and the page script rebuilt. The GPU agrees with the CPU raster for all fourteen shapes at 1× and scaled.Not in this PR
hollowByKey: splitting a layer by level listed each level twice in the legend; it waits for a better spelling.ports-m10.fsxrewrite and retakingdipole.fsx/fields.fsxwithwithColorSymmetricand contour labels.This branch and #57 (M11a) both write to
CHANGELOG.md's Unreleased section anddocs/not-in-1.0.md, so whichever merges second has a small conflict there.