A binned scale: a colour, fill, alpha, shape, size, line type, line width or position scale
that cuts its continuous values into bins at its breaks and gives every value in a bin the same
colour, opacity, shape, size, line type or width, or, for x or y, the same place on its axis.
Giggly.Plot.scale_x_binned/2 and Giggly.Plot.scale_color_binned/2 among others record one
with the options they are given and no range, and Giggly.panel_scales/2 returns an axis's
trained. Its fields:
transform: the transformation its values are put through before it sees them, so its range, limits and breaks are in transformed space::identity, or any other transformation of numbersScales.Transformnames. Its breaks are found, and its limits widened, in data units, its breaks and limits given in data units, and its labels written in data units.range: the range of the finite numbers it has seen, in transformed space, or:nonebefore it has seen any.palette: what gives each bin its value::identityfor a position, each value placed at its bin's number, counting from 1 at the lowest, before the stat, and each position put back into its bin once the stat and position have moved it;{:binned, palette}, a discrete palette ofScales.Palette's, such as{:binned, {:brewer, %{palette: "Blues", direction: -1}}},{:binned, {:shape, :solid}}or{:binned, :linetype}, its colours, shapes or line types for as many levels as there are bins, the first for the lowest; or a continuous palette, such as{:gradient, colors}for colour,{:rescale, {low, high}}for alpha or line width,{:area, {low, high}}or{:abs_area, max}for size, or any other ofScales.Palette's, its value at the middle of each bin's place in the limits; or{:theme, fallback}, a scale given no palette, asGiggly.Plot.scale_color_binned/2records it, andGiggly.Plot.scale_alpha_binned/2and its kin given norange:, which takes the theme's continuous palette for its aesthetic (Giggly.Plot.theme/2'spalette_color_continuous:and the rest) at each bin's middle, or elsefallback, the function's own, when the plot is run.rescaler: how a value's place in the limits is found::rescale, its distance from the low end over the limits' width; or{:mid, midpoint}, its distance from the midpoint over twice the further end's, so the midpoint is at the middle and the further end at 0 or 1; or:max, the value over the limits' high end, so 0 is at 0, as size by area places it. Under:maxa high end of 0 places nothing, and a high end below 0 places the edges high to low and hands the bins' values out in reverse, as R does: the lowest values take what the palette gives the middle of the highest values' places, and the highest the lowest's. Or a function of the values and the limits, both in transformed space, that returns a place for each, called on the values and again on the bins' edges, asGiggly.Plot.scale_color_steps/2and its kin recordrescaler:.na_value: what a missing value, one not a finite number, or oneoobleaves outside the limits maps to: for colour or fill grey,"#7F7F7F", or:none, no colour; for alpha, size or line width a number, for shape a shape by name, asGiggly.Plot.geom_point/3'sshape:names one, for line type a dash pattern,{}solid; ornil, the colour's own opacity, no point or line drawn, or, for a position, no place, so its mark is not drawn.guide: the guide that draws it::colorsteps, for colour or fill, a bar of one block of colour for each bin;:bins, a key for each bin;:legend, a key for each break; for a position:default, the axis its coordinate system draws for it, or:axis, an axis beside the panel; a guide's struct its options make; or:nonefor none.aesthetics: the aesthetics other than position it serves, in the order it trains on them, asGiggly.Plot'saesthetics:option names them: one scale trained once over every one of them, each drawing its own guide; its own aesthetic alone by default, and:nonefor a position.position: the side of the panels a position's axis goes on,:bottomor:topfor x,:leftor:rightfor y, or:nonefor the coordinate system's own, below and left; an aesthetic other than position reads none.expand: how far a position's axis reaches beyond its limits,[mult: {low, high}, add: {low, high}]: at each end, that multiple of the limits' width plus that constant; an aesthetic other than position reads none.name: its guide's title,:nonefor none, or:defaultfor the title its mapping gives.limits:{low, high}, in data units, the values it spans whatever the data,nilat an end the data decides; transformed, and sorted when both are given. Or a function, handed the trained range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits in data units, kept in the order returned and never widened. A value outside them is handled asoobsays. With neither end given and its breaks the default, the limits are the data's range widened in data units so the end bins are as wide as their neighbours: from the lowest break inside the range less the step to the next, to the highest plus the step from the one before; with one break inside, so it is the middle, from it less its distance to the further end of the range to it plus the same; with none inside, not widened, its ends its breaks, and a range of one value widened by 0.05 either side first. A widened end the transformation cannot place, such as 0 or below under a logarithm, is left at the range's end, and a break there left out.oob: what happens to a value outside the limits before it is binned, as a continuous scale'soobsays::squish, a finite number moved onto the nearer limit, so it takes the colour of the bin at that end; any other ofGiggly.Scale.Continuous's; a value still outside, or missing, maps tona_value.breaks: the values its bins are cut at, beside the limits, in data units: a list, those the transformation places inside the limits kept, in the order given; a function handed the limits in data units,{low, high}, and for one of two arguments[n: n_breaks]too, that returns them, or{value, label}pairs, a pair's label the break's unlesslabelssays otherwise, kept as a list's are, the limits not widened;:nonefor one bin; or:defaultfor aboutn_breaks, chosen asnice_breakssays on the limits in data units, those at either end of the data's range left out where the limits are widened.n_breaks: how many default breaks are wanted, or a breaks function of two arguments is asked for; nice breaks may number a few more or fewer.:defaultasks the transformation's breaks for their own number, five for every built-in one, and hands a breaks function, or spaces evenly, 5.nice_breaks:truefor default breaks chosen as the transformation chooses a continuous scale's, round numbers by default,n_breaksof them wanted, 2 or more but under a logarithm;falseforn_breaksbreaks spaced evenly in data units between the ends of the limits, 1 or more.labels: a label for each break: a list, one for each of its given breaks, or of its default ones, a break left out taking its label with it, each a string or a label another library lays out (Giggly.Label),nilfor a missing one; a function handed every break kept, in data units, that returns their labels, each a string, a power (Scales.Labels.log/2), a label another library lays out ornil;:nonefor none; or:default, each written as a continuous scale under its transformation writes a break, in data units.right: where a value on a break falls:truein the bin below it,falsein the bin above; the lowest value is in the lowest bin, and the highest in the highest.show_limits:trueto have colour steps label the ends of the bar, or a binned legend the ends of its keys, with the limits, written by itslabelsas its breaks are, unless a break is already there;falsefor the breaks alone. A legend shows the breaks alone either way.
A binned position's bins are fixed before the stat, on the range of the values the layers map to its axis, and are not trained again once the stat and position have moved the marks: a bar is placed back into its bin by its share of a bin's width, so a bar 0.9 of a bin wide covers 0.9 of its bin whatever the bin's width, and a position outside every bin has no place.
Summary
Types
@type t() :: %Giggly.Scale.Binned{ aesthetics: :none | [atom()], breaks: :default | :none | [number()] | ({float(), float()} -> list()) | ({float(), float()}, keyword() -> list()), expand: [mult: {number(), number()}, add: {number(), number()}], guide: :colorsteps | :bins | :legend | :default | :axis | :none | struct(), labels: :default | :none | [String.t() | nil] | ([float()] -> [Scales.Labels.power_label()]), limits: {number() | nil, number() | nil} | ({float(), float()} -> {number(), number()}), n_breaks: :default | pos_integer(), na_value: String.t() | :none | number() | atom() | tuple() | nil, name: :default | :none | String.t(), nice_breaks: boolean(), oob: Giggly.Scale.Continuous.oob(), palette: :identity | {:binned, Scales.Palette.t()} | Scales.Palette.t() | {:theme, Scales.Palette.t()}, position: :none | :bottom | :top | :left | :right, range: :none | {number(), number()}, rescaler: Giggly.Scale.Continuous.rescaler(), right: boolean(), show_limits: boolean(), transform: Scales.Transform.name() }