Describes a plot: its data, a mapping from aesthetics to columns, and layers added with a pipe.
rows
|> Giggly.Plot.new(%{x: :wt, y: :mpg})
|> Giggly.Plot.geom_point()A plot is a value and draws nothing itself: Giggly.to_svg/2 draws it, and
Giggly.layer_data/2 shows the table a layer computes.
Data
The data is anything implementing Table.Reader: a list of maps, a map of columns, an Explorer
data frame. new/2 reads it into a Giggly.DataFrame, and put_data/2 replaces it with
another table. A layer can draw a table of its own instead, given by its data: option; under a
facet, a table lacking the faceting columns is drawn in every panel. A plot may have no data,
new/0, each layer then bringing its own table or mapping only constants, which draw one mark,
as geom_function/3 needs none:
iex> mtcars = %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => [6, 4, 8]}
iex> frame =
...> mtcars
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point(data: %{"wt" => [3.0], "mpg" => [20.0]}, colour: "#D9D9D9")
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.facet_wrap(:cyl)
...> |> Giggly.layer_data(0)
iex> Giggly.DataFrame.pull(frame, :panel)
[1, 2, 3]With Explorer in the project's dependencies, an Explorer data frame, eager or lazy, stays in
Explorer, and a layer drawing it computes there up to its stat, so only the stat's output, a
row a bar or a box, is read into Elixir: a large table draws without crossing over. A layer
does so where every part of it can: the plot has no facet_wrap/3 or facet_grid/2; its stat
computes through the frame's operations (Giggly.Stat.frame_operations?/1), as every one of
Giggly's does but aligning, an area's default; each value it maps before its stat, a staged
value's start among them, is a column, a constant or a function by name, never an Elixir
function, whatever it maps after the stat or the scales; and each scale is through the
identity transformation, an axis's also with no limits, not binned, and its oob:, if given,
:censor, :squish or :keep, so neither a date axis, scale_x_log10/2 nor a size scale
through a logarithm. Any other layer reads its table into
lists where it enters, and every layer draws the same plot either way.
Mapping and setting aesthetics
Every layer function takes a mapping, a map, and options, a keyword list, either or both. A map
maps an aesthetic to a column, %{x: :wt}, or to an expression or a constant, as
Giggly.Mapping describes; a keyword list sets it to one value for every mark, alpha: 0.4.
The plot's mapping applies to every layer, and a layer's own mapping is laid over it;
aes/2 adds to the plot's mapping. An aesthetic mapped to :none is mapped to nothing: a
layer's %{x: :none} leaves out the plot's x for that layer alone, and aes/2's removes it from
the plot's mapping. A column named none is mapped by its name as a string, "none".
A plot is a description, so the order it is built in does not matter: a layer may come before
the plot's data or its mapping, given by put_data/2 and aes/2. A mistake a call can see by itself, such as an unknown option or
an aesthetic a layer cannot use, raises from that call. One that needs the plot's data or
mapping, such as a misspelt column or a missing :x, raises when the plot is run, naming the
function that added the layer. An aesthetic the plot maps that a layer cannot use is ignored by
that layer, so a plot can map :label for its text and still draw points.
Positions
A layer's position: says where its marks move once its stat has run: a position by name,
position: :dodge, or by name in a tuple with its options, position: {:dodge, width: 0.9}.
Each layer function's position: names the positions it takes and its default. A position
given to several layers moves their marks alike, so one bound to a name, dodge = {:dodge, width: 0.9}, lines labels up with the bars they label.
A layer takes every position that can move its marks. Marks with a width of their own, such as
bars, tiles and error bars, take them all. Marks with none, such as points, lines, text, line
ranges and areas, are dodged, either way, only within a width given, {:dodge, width: 0.9} or
{:dodge2, width: 0.5}, since without one neither would move them. Box plots and rectangles are
neither stacked, filled nor jittered, beside dodging or not, and a horizontal or vertical line is
only nudged; a diagonal line takes no position.
Stacking and dodging move marks along x, and horizontal marks along y: those the layer makes
horizontal, such as bars counted along y or a line range from xmin to xmax, and those whose
one discrete axis is y, such as points or labels over a continuous x and a discrete y.
A position a layer's marks do not take raises from the layer function given it, saying why, and so do an option the position does not take, or one that would change nothing for those marks, and a value it cannot use, naming the position.
A plugin's position is its module, adopting Giggly.Position, given alone or in a tuple with
its options, position: {MyPlugin.Lifted, by: 2.0}: every layer function takes it, checked
against the options its module states.
Leaving marks where they are: :identity
Every mark stays where its stat put it. It takes no options.
Piling marks up: :stack
Marks that share an x are piled on one another, the highest group at the bottom, so the pile
matches the legend's order, or the lowest given reverse: true; those reaching below zero pile
downward from it. Each mark takes the stretch of its pile as long as its y, and its y moves
to the stretch's top, or as far up it as vjust: says, so vjust: 0.5 sets a label in the
middle of the bar it labels. Bars and areas pile this way by default.
:vjust- Where in its stretch of the pile each mark'symoves, any number: 0 its bottom, 0.5 its middle, 1 its top. The default value is1.0.:reverse(boolean/0) - Whether the pile runs from the lowest group at the bottom to the highest. The default value isfalse.iex> frame = ...> %{"x" => ["a", "a"], "y" => [2.0, 3.0], "g" => ["p", "q"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, label: :g, colour: :g}) ...> |> Giggly.Plot.geom_text(position: {:stack, vjust: 0.5}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [4.0, 1.5]
Piling marks to one height: :fill
Marks are piled as :stack piles them, then each pile is scaled to reach 1, so the marks at an
x show their shares of its total; a pile below zero reaches -1. A pile whose total is 0 is
left as it is, and one holding both infinities, whose total is no number, is not drawn. It
takes stacking's options.
iex> frame =
...> %{"x" => ["a", "a", "b"], "y" => [1.0, 3.0, 2.0], "g" => ["p", "q", "p"]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :g})
...> |> Giggly.Plot.geom_col(position: :fill)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :ymax)
[1.0, 0.75, 1.0]Setting marks side by side: :dodge
The marks of different groups at one position are set side by side. The groups share a width,
each centred in its share, lowest group first, and each mark keeps its own width over the number
of groups. Given no width:, they share the width of the panel's first mark, so a bar dodges
bars, but marks of different widths drawn over them, such as narrower error bars, are dodged
within their own width and miss the bars; give each layer the same width:, the bars' width,
so they line up. A mark with no width of its own, a line range or a point range, is dodged only
within a width: given. A position with one group keeps its mark where it is, unless
preserve: :single, where each mark takes the share it would among the most groups any one
position holds, in any panel, the first share first, so a position with fewer leaves room after
them. reverse: true sets the highest group first. Marks that do not say which way they run,
such as points over two continuous axes, are dodged along y given orientation: :y; a layer
whose marks always say so, bars, box plots, ranges, lines and areas, takes no orientation:.
:width- How wide the space is that the marks at one position share, in the units of the axis they are dodged along, any number; the panel's first mark's width when not given, so marks with no width of their own, such as line ranges, are not moved.:preserve- Whether the marks at a position share the whole width (:total), or each takes the share it would among the most groups any one position holds, the first share first, so a position with fewer leaves room after them (:single). The default value is:total.:orientation- The axis the marks are dodged along where neither the layer nor its data says which way they run: points or text over two continuous axes, say, which:ydodges up the panel. Marks whose one discrete axis isyare dodged along y whatever this says, and a layer whose marks always say which way they run, bars, box plots, ranges, lines and areas, takes none. The default value is:x.:reverse(boolean/0) - Whether the marks at a position run from the highest group to the lowest. The default value isfalse.iex> frame = ...> %{"x" => ["a", "a"], "y" => [2.0, 3.0], "g" => ["p", "q"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, color: :g}) ...> |> Giggly.Plot.geom_linerange(%{ymin: :y, ymax: :y}, position: {:dodge, width: 0.9}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [0.775, 1.225]
With preserve: :single, a bar alone at its position is as wide as each of a pair, in the
first of their places:
iex> frame =
...> %{"x" => ["a", "a", "b"], "y" => [1.0, 2.0, 3.0], "g" => ["p", "q", "p"]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :g})
...> |> Giggly.Plot.geom_col(position: {:dodge, preserve: :single})
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :xmax)
[1.0, 1.4500000000000002, 2.0]Setting bars side by side by their spans: :dodge2
Bars whose spans overlap or meet are dodged together, whatever their groups and widths: each
takes its share of their widths, its own width over their number, and they are laid side by
side in order of group, centred on the middle of the span they covered, each bar's x moving
to its middle. In a panel where some position holds two bars or more, every bar is then
narrowed by padding:, so neighbours stand apart. The layer's rows come out in that order: by
panel, then by x, then by group. A mark with no edges of its own, a point or a line range, is
dodged as a bar width: wide, each row side by side with those it overlaps, whatever their
groups; marks with edges, bars, box plots and error bars, take no width:.
:width- How wide each mark with no width of its own, such as a point or a line range, is taken to be, in the units of the axis it is dodged along, any number, so each is set side by side with the marks it overlaps, whatever their groups; a layer whose marks have widths of their own, bars, box plots and error bars, takes none.:preserve- Whether the bars at a position share their whole width (:total), or each takes its width over the most bars any one position holds, so a position with fewer leaves room (:single). The default value is:total.:padding- How much of its share each bar leaves as a gap, a fraction from 0 to 1, in every panel where some position holds two bars or more. The default value is0.1.:reverse(boolean/0) - Whether the bars at a position run from the highest group to the lowest. The default value isfalse.iex> plot = ...> %{"x" => ["a", "a", "b"], "y" => [1.0, 2.0, 3.0], "g" => ["p", "q", "p"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :g}) ...> |> Giggly.Plot.geom_col(position: {:dodge2, preserve: :single}) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :xmin) [0.5725, 1.0225000000000002, 1.7974999999999999]
iex> frame = ...> %{"x" => [1.0, 1.0], "y" => [2.0, 3.0], "g" => ["p", "q"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, color: :g}) ...> |> Giggly.Plot.geom_point(position: {:dodge2, width: 0.5}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [0.875, 1.125]
Nudging marks: :nudge
Every position a mark has along x moves by its nudge_x and every one along y by its
nudge_y, in the units of each axis: set for every mark by the layer's nudge_x: and
nudge_y:, which every layer function but geom_abline/3 takes, a reference line only along
its own axis, or mapped from a column, each mark its own way, a value set winning over one
mapped. A mark given neither stays where it is, and one whose nudge is missing is not drawn.
Text and labels are nudged unless position: says otherwise. A nudge set or mapped beside
another position raises, which would move nothing, and so does a mapped one that is not numbers,
when the plot is run. It takes no options.
iex> plot =
...> %{"x" => [1.0, 2.0], "y" => [1.0, 2.0], "shift" => [0.5, -0.5]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.geom_point(%{nudge_x: :shift}, position: :nudge)
iex> Giggly.DataFrame.pull(Giggly.layer_data(plot), :x)
[1.5, 1.5]Moving marks a random distance: :jitter
Each mark moves by a distance drawn evenly from minus width: to width: across and from minus
height: to height: up, in the units of each axis; one not given is 0.4 of the closest
spacing of each panel's positions along that axis, 0.4 on a discrete axis, whose levels are 1
apart. The distances are drawn from seed:, each panel's afresh, so the same seed moves the
same rows the same way: a plot draws the same points every time it is drawn, and layers given
one position move rows alike. Every position the layer has along an axis moves by its row's
distance along it; a missing position stays missing, and an infinite one where it is.
:width- How far each point moves at most to either side, in the units of the x axis, 0 or more; 0.4 of the closest spacing of each panel'sxpositions when not given, 0.4 on a discrete axis.:height- How far each point moves at most up or down, in the units of the y axis, 0 or more; 0.4 of the closest spacing of each panel'sypositions when not given.:seed(integer/0) - The seed the random distances are drawn from, any integer: the same seed moves the same rows the same way, so another seed draws other distances. The default value is0.iex> jitter = {:jitter, width: 0.1, height: 0.1, seed: 7} iex> plot = ...> %{"am" => [0, 1], "vs" => [1, 0]} ...> |> Giggly.Plot.new(%{x: :am, y: :vs}) ...> |> Giggly.Plot.geom_point(position: jitter) ...> |> Giggly.Plot.geom_point(position: jitter, colour: "red") iex> plot |> Giggly.layer_data(0) |> Giggly.DataFrame.pull(:x) [0.0673789719000282, 1.0819934130875033] iex> plot |> Giggly.layer_data(1) |> Giggly.DataFrame.pull(:x) [0.0673789719000282, 1.0819934130875033]
Setting marks side by side, then moving them a random distance: :jitterdodge
The marks of different groups at one position are set side by side within dodge_width:, as
{:dodge, width: dodge_width} sets them, then each moves by a distance drawn evenly from minus
to plus its amount to either side, and up and down by up to jitter_height:, 0 unless given, so
points drawn over box plots dodged by the same groups spread across their own group's box. The
sideways amount is jitter_width:, else 0.4 of the closest spacing of the layer's positions,
over every panel, divided by the most groups at one position in any panel plus 2, so the points
of each group keep to their share; the distances are drawn as :jitter draws them, from
seed:. Marks with no width of their own are dodged within dodge_width: too, and so are
marks whose one discrete axis is y, along y. A layer jittered this way needs both x and
y, as :jitter does.
:jitter_width- How far each mark moves at most to either side of its share, in the units of the axis it is dodged along, 0 or more, before it is divided by the most groups at one position in any panel plus 2; 0.4 of the closest spacing of the layer's positions along that axis, over every panel, when not given, 0.4 on a discrete axis.:jitter_height- How far each mark moves at most along the other axis, up or down for marks dodged along x, in that axis's units, 0 or more, so marks move only to the side unless given. The default value is0.0.:dodge_width- How wide the space is that the groups at one position share, in the units of the axis they are dodged along, any number. The default value is0.75.:seed(integer/0) - The seed the random distances are drawn from, any integer: the same seed moves the same rows the same way, so another seed draws other distances. The default value is0.iex> plot = ...> %{"cut" => ["a", "a", "a", "a"], "carat" => [1.0, 2.0, 3.0, 4.0]} ...> |> Map.put("clarity", ["p", "q", "p", "q"]) ...> |> Giggly.Plot.new(%{x: :cut, y: :carat, fill: :clarity}) ...> |> Giggly.Plot.geom_boxplot() ...> |> Giggly.Plot.geom_point(position: :jitterdodge) iex> plot |> Giggly.layer_data(0) |> Giggly.DataFrame.pull(:x) [0.8125, 1.1875] iex> plot |> Giggly.layer_data(1) |> Giggly.DataFrame.pull(:x) [0.8086663925491824, 1.2857778162399303, 0.7413202475792124, 1.1838679705192539]
Colours
A colour is a CSS colour name, such as "steelblue", a hex colour, such as "#4682B4", or
"#4682B480" with an alpha of its own, or "transparent", white with no alpha as R's is, where
CSS's is black; :none draws nothing. A name CSS does not define raises. An alpha, set or
mapped, replaces a colour's own, so "transparent" at an alpha of 0.5 draws half-white.
A discrete column mapped to :color (or :colour) or :fill gives each of its values a hue,
evenly spaced round the colour wheel, so three values are #F8766D, #00BA38 and #619CFF; a
missing value is grey, #7F7F7F, and its key in the legend comes last, labelled NA.
iex> plot =
...> %{"wt" => [2.62, 2.875, 2.32], "mpg" => [21.0, 22.8, 22.8], "cyl" => ["6", "4", nil]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl})
...> |> Giggly.Plot.geom_point()
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color)
["#00BFC4", "#F8766D", "#7F7F7F"]A column of numbers mapped to colour or fill gives each value a colour as far along a gradient
from #132B43 to #56B1F7 as the value is through the column's range; a missing value is grey
here too. Its guide is a colour bar.
iex> plot =
...> %{"wt" => [2.62, 2.875, 2.32], "mpg" => [21.0, 22.8, 22.8], "hp" => [110, 93, nil]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp})
...> |> Giggly.Plot.geom_point()
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color)
["#56B1F7", "#132B43", "#7F7F7F"]A legend, colour bar or colour steps are drawn for each mapped aesthetic, stacked down the right
of the panels unless its guide's position: or the theme puts them elsewhere (theme/2's
legend_position:), a box for each place, in the order of the aesthetics' names (alpha,
color, fill, shape, size). Two with the same
title and labels, such as a colour and a fill mapped to one column, are drawn as one.
Guides
A guide reads a scale back: an axis, ticks and labels beside the panel, for a position; a
legend, a key for each break, or, for a continuous colour or fill, a colour bar, or colour
steps, a bar of one block of colour for each bin between its breaks; or, for a binned or
continuous scale of any of them, a binned legend, a key for each bin. Each scale function's
guide: chooses its scale's, by name, :axis, :axis_logticks, :axis_stack,
:axis_theta, :legend, :colorbar, :colorsteps, :bins or :none for none, or by name in a tuple
with its options, guide: {:axis, angle: 90} or guide: {:colorbar, reverse: true}; guides/2
chooses them by aesthetic over whatever the scales say. An axis given :none draws nothing, its
title kept. An axis goes below or left of the panels unless its scale's position: or its
guide's says otherwise, its title with it, and guides/2's x_sec: and y_sec: draw a copy
of an axis, its breaks and labels with no title, on the side opposite it, or its scale's
secondary axis by the guide they give.
An axis: {:axis, options}
An axis's ticks, labels and line, its labels turned, dealt into rows or thinned where they would overlap as its options say, on the side its options say, its line cut back to its outermost ticks and minor ticks drawn where they ask. Turned, each label is justified to stand clear of its tick, whatever justification the theme gives.
:angle- The labels' angle, in degrees anticlockwise, any number, each label justified to stand clear of its tick whatever the theme's justification; the theme's angle and justification when not given.:n_dodge(pos_integer/0) - How many rows below or above the panel, or columns beside it, the labels are dealt into, the first label into the row nearest the panel, the next into the next, and round again. The default value is1.:position- The side of the panels the axis goes on,:bottomor:topfor x,:leftor:rightfor y, over the scale'sposition:, its title going with it; a copy's (x_sec:,y_sec:) the side opposite the axis when not given. Undercoord_radial/2it moves nothing, as the scale'sposition:places the radius axis.:check_overlap(boolean/0) - Whether a label that would overlap one drawn before it is left out, the first and last labels drawn first, then the middle one, then the middle of each half, and so on, each row of dodged labels apart. The default value isfalse.:cap- Which ends of the axis's line are cut back to its outermost ticks::none,:both,:upperor:lower, the scale's high and low ends, ortruefor:bothandfalsefor:none. The default value is:none.:minor_ticks(boolean/0) - Whether the axis draws a tick at each of its scale's minor breaks, in the theme's minor ticks (axis_minor_ticks_x_bottomand the rest), three quarters as long as the ticks unless it says otherwise. The default value isfalse.
An axis of logarithmic ticks: {:axis_logticks, options}
An axis whose ticks fall at the powers of ten and their multiples, long at each power, middling
at five times it and short at the other whole multiples, its labels at the scale's breaks, which
take no tick of their own. The ticks are placed through the scale's transformation, a log
scale's or any other, or through the logarithm of prescale_base: for data logged before
plotting; where the scale's limits reach 0 or below they are mirrored either side of 0. The
long ticks are drawn in the side's ticks (axis_ticks_x_bottom and the rest), the others in its
minor ticks (axis_minor_ticks_x_bottom). No secondary axis takes it, and neither does a
discrete, date, date-time or time axis, nor an axis under coord_radial/2; an axis's copy,
guides/2's x_sec: or y_sec: for a scale with no sec_axis:, does.
:long- How long the ticks at the powers of ten are:{:rel, share}, a share of the side's tick length (axis_ticks_length_x_bottomand the rest), or{amount, unit}, a length of its own in:pt,:cm,:mm,:inor:lines; a negative one turns the ticks into the panel. The default value is{:rel, 2.25}.:mid- How long the ticks at five times each power are, aslong:takes it. The default value is{:rel, 1.5}.:short- How long the ticks at every other multiple are, aslong:takes it. The default value is{:rel, 0.75}.:prescale_base- The base of the logarithm the data was logged in before plotting, a number above 1, for an axis whose scale has no transformation of its own;:noneplaces the ticks through the scale's transformation. The default value is:none.:negative_small- Where the scale's limits reach 0 or below, the smallest size marked with a tick either side of 0, a finite number from 1.0e-100;:autois a tenth of the largest limit's size, 0.1 at most. The default value is:auto.:expanded(boolean/0) - Whether the ticks cover the axis's whole extent, its expansion included, or only the scale's limits, which a coordinate system's zoom leaves as they are. The default value istrue.:cap- Which ends of the axis's line are cut back to its outermost ticks, as{:axis, options}'scap:takes it. The default value is:none.:angle- The labels' angle, in degrees anticlockwise, any number, each label justified to stand clear of its tick whatever the theme's justification; the theme's angle and justification when not given.:n_dodge(pos_integer/0) - How many rows below or above the panel, or columns beside it, the labels are dealt into, the first label into the row nearest the panel, the next into the next, and round again. The default value is1.:position- The side of the panels the axis goes on,:bottomor:topfor x,:leftor:rightfor y, over the scale'sposition:, its title going with it; a copy's (x_sec:,y_sec:) the side opposite the axis when not given. Undercoord_radial/2it moves nothing, as the scale'sposition:places the radius axis.:check_overlap(boolean/0) - Whether a label that would overlap one drawn before it is left out, the first and last labels drawn first, then the middle one, then the middle of each half, and so on, each row of dodged labels apart. The default value isfalse.
A stack of axes: {:axis_stack, options}
Several axes on one side, the first against the panel and each beyond the one before, each
drawn as it would be alone, its ticks, labels, line, cap and minor ticks its own. A stack takes
its side from its own position: or its scale's, and may hold a stack, drawn as one of its
axes. Under coord_radial/2 a stack on the radius axis is drawn in the theme's left or right
y axis's elements (axis_text_y_left and the rest), not the radius axis's, and a stack round
the circle holds angle axes alone, each a ring beyond the one before, as wide as its labels
reach, drawn in the theme's bottom x axis's elements (axis_text_x_bottom and the rest), not
the angle axis's.
:guides- The axes stacked, the first nearest the panel and each beyond the one before: beside the panel a list of one or more of:axis,:axis_logticksand:axis_stack, each by name or with its options, each drawn on the stack's side and so taking noposition:of its own; round a radial panel's circle,:axis_thetas alone, each a ring beyond the one before.[:axis]when not given. The default value is[:axis].:spacing- The room between two of the axes,{amount, unit}in:pt,:cm,:mm,:inor:lines, any amount, a negative one overlapping them;:autois the side's tick length (axis_ticks_length_x_bottomand the rest) beside the panel and 2.25 points round the circle. The default value is:auto.:position- The side of the panels the axis goes on,:bottomor:topfor x,:leftor:rightfor y, over the scale'sposition:, its title going with it; a copy's (x_sec:,y_sec:) the side opposite the axis when not given. Undercoord_radial/2it moves nothing, as the scale'sposition:places the radius axis.
The angle axis: {:axis_theta, options}
The axis round a radial panel's circle, drawn inside the panel over its layers: a tick at each
break reaching out from the circle, its label beyond it, each justified by its break's angle to
stand clear of the circle, and a line round the circle's edge where the theme draws one. It is
the angle's axis under coord_radial/2 when no guide is given; no axis beside a panel takes
it.
:angle- The labels' angle, in degrees anticlockwise from the way the circle runs at each label's break, any number, so 0 lays each along the circle; a label that would read upside down is turned half round, and each is justified to stand clear of the circle whatever the theme's justification. The theme's angle when not given.:minor_ticks(boolean/0) - Whether the axis draws a tick at each of its scale's minor breaks, in the theme'saxis_minor_ticks_theta, its labels moved out beyond them where they are the longer. The default value isfalse.:cap- Which ends of the axis's line round the circle are cut back to its outermost ticks, as{:axis, options}'scap:takes it. The default value is:none.
A legend: {:legend, options}
A key for each of the scale's breaks, labelled, its keys in the order its options choose. Legends of the same guide, order and title with the same labels merge into one, a key holding every aesthetic's value; an option one of their guides gives and the other leaves unset holds for the merged legend, and one they give different values raises when the plot is run.
A guide's theme: takes theme/2's settings, or a theme of settings alone, and draws that guide alone in them, laid over the
plot's theme: here the colour legend's two labels are red, and the shape legend's keep the
theme's ink.
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8], "cyl" => ["4", "6"], "am" => ["0", "1"]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl, shape: :am})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.guides(colour: {:legend, theme: [legend_text: [colour: "red"]]})
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> length(Regex.scan(~r/<text[^>]*fill: #FF0000/, svg))
2:title- The guide's title, a string, a label (Giggly.Label) or:nonefor none, over the scale'sname:andlabs/2; the scale's title when not given. Guides of different titles never merge.:order- Where the guide stands among the plot's legends, 1 first, a whole number to 99; guides not given one after those given one, as if 99, each set in the order of their aesthetics' names. Guides of different orders never merge.:direction- Which way the keys run,:verticalor:horizontal, over the theme'slegend_direction; when neither says, across above or below the panels and down elsewhere.:position- Where the guide goes,:right,:left,:topor:bottomof the panels or:insidethem, over the theme'slegend_position; guides going to one place stack in one box, and an inside guide goes at its own theme'slegend_position_insideandlegend_justification_inside, else the plot's, a box for each point. The theme'slegend_position: :nonedraws no guide, this one included.:theme- The guide's own theme, any oftheme/2's settings, checked as it checks them, or a theme of settings alone thattheme/2returned, but not a complete theme, laid over the plot's theme for this guide alone, so[legend_text: [size: 14]]keeps the plot's label colour, and an element the plot removed is drawn as given. Itslegend_directionruns the keys wheredirection:does not say; an element the guide does not draw, such aslegend_positionor the box's, changes nothing. A key length it gives a colour bar or colour steps,legend_key_heightrunning up andlegend_key_widthacross, is the whole bar's, where the plot's is a key's, five making the bar. Guides that merge keep each one's elements, and an element both give different values raises when the plot is run.:nrow(pos_integer/0) - How many rows the keys take, a whole number from 1; with noncol:, as many columns as they then need. When neither is given, a row for each five keys running across, and a column for each twenty running down.:ncol(pos_integer/0) - How many columns the keys take, a whole number from 1; with nonrow:, as many rows as they then need. Given besidenrow:, the two must hold every key, or the plot raises when run.:reverse(boolean/0) - Whether the keys run from the last break down to the first, the key of a missing value first. The default value isfalse.:override_aes- The looks every key is drawn in over the layers' own, a keyword list ofalpha:,colour:,fill:,shape:,size:,stroke:,linewidth:,linetype:,label:,angle:,hjust:,vjust:,family:andfontface:, each checked as the layer option of its name:[size: 4]draws every key's point at size 4 whatever size the layers draw theirs, and[colour: "black"]every key of a colour legend black. Each takes one value for every key or a list of one per key, in the order the keys are drawn, the key of a missing value and keys no layer draws in counted,:nonedrawing no such mark in its key where the layer option takes it; a list of another length raises when the plot is run. Every layer drawing in the legend takes them, a look its geom does not draw with changing nothing, and a key grows to hold a bigger glyph. A text or label key drawslabel:in place of the letter "a". Guides that merge keep each one's looks, and a look both give different values raises when the plot is run.
A colour bar: {:colorbar, options}
A continuous colour or fill scale's colours as a bar, a tick and a label at each break; it
merges with another as a legend does. The theme's legend_frame borders the bar. Drawn as
five rectangles at half opacity:
iex> svg =
...> %{"wt" => [2.62, 2.875, 3.215], "mpg" => [21.0, 22.8, 21.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.guides(colour: {:colorbar, display: :rectangles, bins: 5, alpha: 0.5})
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> length(Regex.scan(~r/<rect[^>]*fill-opacity: 0.50/, svg))
5:title- The guide's title, a string, a label (Giggly.Label) or:nonefor none, over the scale'sname:andlabs/2; the scale's title when not given. Guides of different titles never merge.:order- Where the guide stands among the plot's legends, 1 first, a whole number to 99; guides not given one after those given one, as if 99, each set in the order of their aesthetics' names. Guides of different orders never merge.:direction- Which way the keys run,:verticalor:horizontal, over the theme'slegend_direction; when neither says, across above or below the panels and down elsewhere.:position- Where the guide goes,:right,:left,:topor:bottomof the panels or:insidethem, over the theme'slegend_position; guides going to one place stack in one box, and an inside guide goes at its own theme'slegend_position_insideandlegend_justification_inside, else the plot's, a box for each point. The theme'slegend_position: :nonedraws no guide, this one included.:theme- The guide's own theme, any oftheme/2's settings, checked as it checks them, or a theme of settings alone thattheme/2returned, but not a complete theme, laid over the plot's theme for this guide alone, so[legend_text: [size: 14]]keeps the plot's label colour, and an element the plot removed is drawn as given. Itslegend_directionruns the keys wheredirection:does not say; an element the guide does not draw, such aslegend_positionor the box's, changes nothing. A key length it gives a colour bar or colour steps,legend_key_heightrunning up andlegend_key_widthacross, is the whole bar's, where the plot's is a key's, five making the bar. Guides that merge keep each one's elements, and an element both give different values raises when the plot is run.:angle- The labels' angle, in degrees anticlockwise, any number, each label justified to stand clear of the bar whatever the theme's justification; the theme's angle and justification when not given.:reverse(boolean/0) - Whether the colours run from the scale's high end to its low, the breaks with them. The default value isfalse.:display- How the bar is drawn::gradient, a gradient through its colours;:rectangles, a rectangle of each colour end to end; or:raster, an image of a cell of each colour, which a viewer blends. Drawn as rectangles or an image, each colour is the scale's at its cell's middle, so the ticks run from the first cell's middle to the last's. The default value is:gradient.:bins(pos_integer/0) - How many colours the bar is drawn through, sampled evenly from the scale's low end to its high, a whole number from 1; 15 for a gradient and 300 for rectangles or an image when not given.:alpha- The opacity the bar's colours are drawn at, from 0 to 1, in place of their own; their own when not given.:end_ticks- Which of the ticks at the first and last breaks are drawn::both,:none,:upper, the last's alone, or:lower, the first's alone, the breaks counted in the order the scale gives them, so the scale's low end first even whenreverse:turns the bar; ortruefor:bothandfalsefor:none. Their labels are drawn either way. The default value is:both.
Colour steps: {:colorsteps, options}
A binned or continuous colour or fill scale's bins as a bar of one block of colour each, each
break's label at the edge it sits at; it merges with another as a legend does. The bins are all
as long unless even_steps: false places them by value; here three bins at half opacity:
iex> svg =
...> %{"wt" => [2.62, 2.875, 3.215], "mpg" => [21.0, 22.8, 21.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.scale_color_binned(breaks: [21.5, 22])
...> |> Giggly.Plot.guides(colour: {:colorsteps, even_steps: false, alpha: 0.5})
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> length(Regex.scan(~r/<rect[^>]*fill-opacity: 0.50/, svg))
3:title- The guide's title, a string, a label (Giggly.Label) or:nonefor none, over the scale'sname:andlabs/2; the scale's title when not given. Guides of different titles never merge.:order- Where the guide stands among the plot's legends, 1 first, a whole number to 99; guides not given one after those given one, as if 99, each set in the order of their aesthetics' names. Guides of different orders never merge.:direction- Which way the keys run,:verticalor:horizontal, over the theme'slegend_direction; when neither says, across above or below the panels and down elsewhere.:position- Where the guide goes,:right,:left,:topor:bottomof the panels or:insidethem, over the theme'slegend_position; guides going to one place stack in one box, and an inside guide goes at its own theme'slegend_position_insideandlegend_justification_inside, else the plot's, a box for each point. The theme'slegend_position: :nonedraws no guide, this one included.:theme- The guide's own theme, any oftheme/2's settings, checked as it checks them, or a theme of settings alone thattheme/2returned, but not a complete theme, laid over the plot's theme for this guide alone, so[legend_text: [size: 14]]keeps the plot's label colour, and an element the plot removed is drawn as given. Itslegend_directionruns the keys wheredirection:does not say; an element the guide does not draw, such aslegend_positionor the box's, changes nothing. A key length it gives a colour bar or colour steps,legend_key_heightrunning up andlegend_key_widthacross, is the whole bar's, where the plot's is a key's, five making the bar. Guides that merge keep each one's elements, and an element both give different values raises when the plot is run.:angle- The labels' angle, in degrees anticlockwise, any number, each label justified to stand clear of the bar whatever the theme's justification; the theme's angle and justification when not given.:reverse(boolean/0) - Whether the bins run from the scale's high end to its low, the breaks with them. The default value isfalse.:even_steps(boolean/0) - Whether every bin is drawn as long as the others, each break counted along the bar, or,false, each as long as the values it holds, each break at its value. Placed by value, a continuous scale's bar runs on to its breaks beyond its limits, the bins there in its missing colour, and the limitsshow_limits:labels sit at the bar's ends. The default value istrue.:show_limits(boolean/0) - Whether the bar's ends are labelled with the scale's limits, written as its labels write its breaks, an end a break's label already sits at left as it is; a scale whose labels are a list raises when the plot is drawn. The scale'sshow_limits:when not given, else not.:alpha- The opacity the bins' colours are drawn at, from 0 to 1, in place of their own; their own when not given.
A binned legend: {:bins, options}
A binned or continuous scale's bins as a key each, drawn by the layers as a legend's keys are
and set side by side, each break's label at the edge between two keys, with an axis line along
the keys and a tick at each break; it merges with another as a legend does. The ends of the keys
are labelled with the scale's limits only where show_limits: true says, or a break sits on
one; here a continuous size scale's four bins, the limits shown, its last labels:
iex> svg =
...> %{"wt" => [2.62, 2.875, 3.215], "mpg" => [21.0, 22.8, 21.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.guides(size: {:bins, show_limits: true})
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> ~r{>([^<]+)</text>} |> Regex.scan(svg, capture: :all_but_first) |> Enum.take(-5)
[["21.0"], ["21.5"], ["22.0"], ["22.5"], ["22.8"]]:title- The guide's title, a string, a label (Giggly.Label) or:nonefor none, over the scale'sname:andlabs/2; the scale's title when not given. Guides of different titles never merge.:order- Where the guide stands among the plot's legends, 1 first, a whole number to 99; guides not given one after those given one, as if 99, each set in the order of their aesthetics' names. Guides of different orders never merge.:direction- Which way the keys run,:verticalor:horizontal, over the theme'slegend_direction; when neither says, across above or below the panels and down elsewhere.:position- Where the guide goes,:right,:left,:topor:bottomof the panels or:insidethem, over the theme'slegend_position; guides going to one place stack in one box, and an inside guide goes at its own theme'slegend_position_insideandlegend_justification_inside, else the plot's, a box for each point. The theme'slegend_position: :nonedraws no guide, this one included.:theme- The guide's own theme, any oftheme/2's settings, checked as it checks them, or a theme of settings alone thattheme/2returned, but not a complete theme, laid over the plot's theme for this guide alone, so[legend_text: [size: 14]]keeps the plot's label colour, and an element the plot removed is drawn as given. Itslegend_directionruns the keys wheredirection:does not say; an element the guide does not draw, such aslegend_positionor the box's, changes nothing. A key length it gives a colour bar or colour steps,legend_key_heightrunning up andlegend_key_widthacross, is the whole bar's, where the plot's is a key's, five making the bar. Guides that merge keep each one's elements, and an element both give different values raises when the plot is run.:angle- The labels' angle, in degrees anticlockwise, any number, each label justified to stand clear of the keys whatever the theme's justification; the theme's angle and justification when not given.:reverse(boolean/0) - Whether the keys run from the highest bin to the lowest, the breaks' labels with them. The default value isfalse.:show_limits(boolean/0) - Whether the ends of the keys are labelled and ticked with the scale's limits, written as its labels write its breaks, an end a break sits on shown with that break's label either way; a scale whose labels are a list raises when the plot is drawn. The scale'sshow_limits:when not given, else not.:override_aes- The looks every key is drawn in over the layers' own, a keyword list ofalpha:,colour:,fill:,shape:,size:,stroke:,linewidth:,linetype:,label:,angle:,hjust:,vjust:,family:andfontface:, each checked as the layer option of its name:[size: 4]draws every key's point at size 4 whatever size the layers draw theirs, and[colour: "black"]every key of a colour legend black. Each takes one value for every key or a list of one per key, in the order the keys are drawn, the key of a missing value and keys no layer draws in counted,:nonedrawing no such mark in its key where the layer option takes it; a list of another length raises when the plot is run. Every layer drawing in the legend takes them, a look its geom does not draw with changing nothing, and a key grows to hold a bigger glyph. A text or label key drawslabel:in place of the letter "a". Guides that merge keep each one's looks, and a look both give different values raises when the plot is run.
Secondary axes
A position scale's sec_axis: draws a secondary axis opposite its axis, labelling the same
places in other units: given a function of one value, such as fn mpg -> mpg * 0.425 end
turning miles per gallon into kilometres per litre, each of the axis's values is turned into the
secondary axis's, and the secondary axis is marked at round values of its own. The function must
be strictly increasing or decreasing over the data, and is handed values across the whole
widened axis, which may lie beyond the data, where it may return nil for none; a function
that raises there, as :math.sqrt/1 does below 0 on an axis widened past it, raises from the
plot, so one that has no value somewhere says so with a clause:
fn
mileage when mileage >= 0 -> :math.sqrt(mileage)
_negative -> nil
endOn a date, date-time or time axis it is handed values of the column's type and must shift every
value alike, as &DateTime.add(&1, 8, :hour) shifts a time zone's clock. A discrete axis's
secondary axis is a copy of it.
sec_axis: :duplicate copies the axis, its title, breaks, labels and guide; {:duplicate, options} copies it with those options its own; a keyword list gives a secondary axis its own
options, each given :derive taking the axis's. A secondary axis is drawn by an axis beside the
panel unless its guide: says otherwise, and guides/2's x_sec: or y_sec: sets its guide
over its own; given :none it draws nothing, its title kept. Under coord_radial/2 the
radius's scale's secondary axis is drawn opposite the radius axis, and the angle's is refused.
:transform(function of arity 1) - The function of one value that turns each of the axis's values, in data units, into the secondary axis's, strictly increasing or decreasing over the data; on a date, date-time or time axis, handed a value of the column's type, one that shifts every value alike, such as&DateTime.add(&1, 8, :hour). The identity when not given.:name- The secondary axis's title,:nonefor none, or:derivefor the axis's own;:nonewhen not given, and:derivebeside:duplicate.:breaks- The values the secondary axis marks, in its own units, as the scale'sbreaks:takes them, or:derivefor the axis's own, read in the secondary axis's units; chosen by the axis's transformation, in data units, when not given.:labels- The breaks' labels, as the scale'slabels:takes them, a function handed the breaks in the secondary axis's units, or:derivefor the axis's own; written as suits the breaks when not given.:guide- What reads the secondary axis back, as the scale'sguide:takes it, or:derivefor the axis's own; an axis beside the panel when not given.
Scales
Each axis gets a scale from the type of what is mapped to it: a continuous scale for numbers, a
discrete one for text, booleans and factors, a date one for dates, a date-time one for
DateTimes and NaiveDateTimes, and a time one for Times. scale_x_continuous/2,
scale_x_discrete/2, scale_x_date/2, scale_x_datetime/2 and scale_x_time/2, and their y
twins, set an axis's title, limits, breaks, labels and how far it reaches, and a date-time
axis's time zone; xlim/3, ylim/3 and lims/2 set its limits alone, two ends for a
continuous, a date or a date-time axis and, with xlim/2 and ylim/2, a list of values for a
discrete one; a time axis's are its scale's limits:. A value outside the limits is missing, so
its mark is not drawn, unless the scale's oob: says otherwise. A continuous scale given a column of dates places each at its days since
1970-01-01, one of date-times each at its seconds since 1970-01-01 00:00 UTC, and one of times
each at its seconds since midnight.
A label on an axis or a legend breaks over lines where it holds " ", and a missing one,
nil, is drawn NA. A labels function may return powers, as Scales.Labels.log/2 does, drawn
as a base with a smaller exponent raised after it, a sign before it in the symbol font; where
any label of an axis or a colour bar is a power, its strings are placed as powers are and a
missing one is drawn as nothing; a legend draws each key's label alone, a string as text and a
missing one NA.
A colour, fill, alpha, shape or size scale chooses how values become colours, opacities, shapes or
sizes, and sets its legend's title, limits, breaks and labels: scale_color_manual/2 names each
value's colour, scale_color_hue/2 spaces hues round the colour wheel, scale_color_gray/2
greys, scale_color_discrete/2 either, and scale_color_viridis_d/2 takes colours from a
viridis palette, as an ordered factor gets by default, scale_color_ordinal/2 the same or a
blend through the colours of type:, and scale_color_brewer/2 from a ColorBrewer palette; scale_color_gradient/2, scale_color_gradient2/2,
scale_color_gradientn/2 and scale_color_continuous/2 blend a gradient through two, three or
any number of colours, scale_color_viridis_c/2 through a viridis palette and
scale_color_distiller/2 through a ColorBrewer palette; each has a scale_fill_ twin, and
scale_alpha_continuous/2, scale_alpha_discrete/2 and scale_alpha_ordinal/2 set opacities.
scale_size_continuous/2 and scale_size_area/2 size points by area, the second from 0,
scale_radius/2 by width, and scale_size_discrete/2 and scale_size_ordinal/2 a discrete
column's values in order. scale_alpha_binned/2,
scale_size_binned/2, scale_size_binned_area/2 and scale_linewidth_binned/2 cut a column
into bins at their breaks, as the binned colour scales do, each bin one opacity, size or line
width. scale_shape_discrete/2 gives a discrete column's values six shapes, solid or open, and
scale_shape_manual/2 names each value's shape; shapes have no order, so a continuous column
is mapped to :shape only binned, by scale_shape_binned/2, and to :linetype only by
scale_linetype_binned/2. scale_color_identity/2, scale_fill_identity/2,
scale_alpha_identity/2, scale_shape_identity/2, scale_size_identity/2,
scale_linetype_identity/2 and scale_linewidth_identity/2 scale nothing: a column that holds
colours, shapes or sizes is drawn in them as it stands, with no legend unless guide: :legend
asks for one. lims/2 sets their limits alone. A value outside a colour scale's limits takes its na_value:, as a missing
one does, unless its oob: says otherwise; a binned scale's, of any aesthetic, is binned at the
nearer end.
One scale may serve several aesthetics whose values it holds alike, colour and fill, or any of
alpha, size and line width: each of these functions takes aesthetics:, and
scale_discrete_manual/3, scale_discrete_identity/3 and scale_continuous_identity/3 take
the aesthetics first, the identity ones any mix. The scale is trained once over all of them and
maps each, every aesthetic drawing its own legend under its own title, so colour mapped to
cylinders and fill to gears share one palette over both columns' values. A later scale serving
any of them replaces it whole, the others falling back to their defaults.
Labels
Each axis and legend is titled by what is mapped to it, as Giggly.Mapping describes. labs/2
titles them otherwise, and gives the plot a title, a subtitle, a caption and a tag; a scale's
name titles its axis over both.
Theme
Everything but the marks is drawn in ggplot2's default theme, a grey panel with white grid lines,
unless a complete theme replaces it: theme_bw/2, theme_linedraw/2, theme_light/2,
theme_dark/2, theme_minimal/2, theme_classic/2, theme_void/2 or theme_test/2, or
theme_gray/2, the
default, each at a base size of its own. theme/2 changes any element of it by name, each
inheriting what it leaves unset from its parent in ggplot2's tree, so setting
text: [size: 14] makes every label bigger, and axis_text_x: [color: "red"] reddens only the
x axis's labels. An element set to :none is removed, with everything that inherits from it.
The shortcuts set one part's elements by shorter names: theme_sub_axis/2, theme_sub_axis_x/2,
theme_sub_axis_y/2, one for each side's axis (theme_sub_axis_bottom/2, theme_sub_axis_top/2,
theme_sub_axis_left/2, theme_sub_axis_right/2), theme_sub_legend/2, theme_sub_panel/2,
theme_sub_plot/2 and theme_sub_strip/2, so theme_sub_axis_bottom(text: [color: "red"]) is
theme(axis_text_x_bottom: [color: "red"]).
legend_position: puts the legends left, right, above or below the panels, inside them, or
nowhere (:none).
Summary
Types
An aesthetic's name, such as :x, :y or :color.
An end of an axis's limits: a number, a date or a date-time, or nil for the data's.
A column of a table as written: its name as an atom or a string.
How positions are placed in each panel: a coordinate system's struct.
How the plot's rows are split into panels: a facet's struct.
A facet as written: what a mapping maps an aesthetic to, named by its text, or {name, value},
the value named by an atom or a string.
The guide that reads an aesthetic's scale back: :axis, :axis_logticks, :axis_theta,
:axis_stack, :legend, :colorbar, :colorsteps, :bins, :none for none, or the axis or
legend {:axis, options}, {:axis_logticks, options}, {:axis_theta, options},
{:axis_stack, options}, {:legend, options} or another guide's options make, as the plot
records it.
The labels labs/2 sets, by what each titles: an aesthetic's guide, or the plot's :title,
:subtitle, :caption or :tag; each its text, or :none for none; and its :alt text,
which may also be a function of the plot.
A mapping as stored: aesthetic to its value resolved, each column it reads named as a string, in the table the layer draws.
A mapping as written: aesthetic to a column, an expression or a constant.
The scales the plot sets, by aesthetic: each a scale's struct, as yet untrained.
The look everything but the marks is drawn in, a plot's or one kept apart from any: the
complete theme a theme_* function chose, by name with its colours, base sizes and families,
:none for a header family not given, or :none for none, which draws the plot in theme_gray/2's
at its defaults, and the settings theme/2 has laid over it, by element, a line's, a
rectangle's or a text's properties as a map, {:replace, properties} where it replaces the
element whole, and :none where it is removed.
Functions
The plot with mapping added to its mapping: each aesthetic mapping maps replaces the plot's
mapping of it, one it maps to :none removed, and the plot's others are kept.
Adds an annotation: a layer drawn from values given here rather than from the data's columns,
for a label, a shaded rectangle or a line placed by hand. geom names what draws it: :blank,
:point, :col or :bar, :path, :line, :segment, :curve, :spoke, :rug,
:linerange, :pointrange, :errorbar, :crossbar, :text, :label or :rect.
Adds a custom annotation: SVG markup of your own, or a plot, drawn over a rectangle placed by
its corners, from xmin: to xmax: across and from ymin: to ymax: up, the same drawing in
every panel. A corner not given is the panel's edge, so given none it fills the panel.
Adds a raster annotation: an image, given as a grid of colours, stretched over a rectangle placed
by its corners, from xmin: to xmax: across and from ymin: to ymax: up, the same image in
every panel. It is drawn faster and smaller than the tiles geom_raster/3 would draw for it.
Draws the plot in cartesian coordinates, x across each panel and y up it, replacing any
coordinate system the plot had. A plot is cartesian until another is chosen, each panel cut off
at its edges; with clip: :off what is drawn may run past them, as rugs drawn outside the
panel do.
Draws the plot in cartesian coordinates whose units keep a fixed ratio on the page, replacing any
coordinate system the plot had: a unit of y is ratio: times as long as a unit of x, 1 unless
given, so each panel's shape follows its extents whatever the drawing's size, as
coord_cartesian/2 draws it given ratio:. It takes every option coord_cartesian/2 takes.
Every panel takes the first one's shape, so a facet freeing either axis's scales is refused
when the plot is run, unless facet_grid/2's space: :free sizes every panel by its scales'
lengths, a unit as long in every panel.
Draws the plot in radial coordinates, replacing any coordinate system the plot had: x is the
angle, running clockwise round a full circle from 12 o'clock, or from start: to end:, and y
the radius, out from the centre, or with theta: :y the other way round, so a stacked bar of
one column becomes a pie.
Draws the plot in cartesian coordinates whose axes are each put through a transformation of
their own once the stats have run, replacing any coordinate system the plot had: x: :log10
spaces the x axis logarithmically while every stat, a smooth's fit and a histogram's bins among
them, sees the data as it is, where a scale's transform: changes what the stats see. A
straight line in the data bends in the panel, so lines, polygons, axis lines and the sides of
rectangles, bars and tiles are cut into steps that follow the bend.
Splits the plot into a grid of panels: a row of panels for each combination of values of the
rows: facets that occurs in the data, and a column of panels for each of the cols: facets',
each side a facet or a list of them, as facet_wrap/3 takes its facets:
facet_grid(plot, rows: :drv, cols: :cyl). Leaving one out gives a single column or a single
row of panels.
Splits the plot into panels, one for each combination of values of the facets that occurs in
the data, laid out in rows. facets is a facet or a list of them: facet_wrap(plot, :class) or
facet_wrap(plot, [:cyl, :drv]). A facet is whatever a mapping maps an aesthetic to, a column,
an expression, a factor, a reordering or a cut, computed in each row of each table: {:reorder, [:class, :displ]} orders the panels by each class's mean displ, and {:cut_width, [:displ], width: 1} makes a panel of each litre of it. It is named by its text, as an
axis is titled, so a column by its own name and {&Kernel.*/2, [:cyl, 2]} as cyl * 2, or by
the name {name, value} gives it, an atom or a string: facet_wrap(plot, [:drv, cylinders: :cyl]). A facet's name is the one its strips' labeller writes and its columns: names it by.
Adds a layer of diagonal reference lines: a line across the whole panel for each intercept
and slope, y = intercept + slope * x, for a line of equality, a fitted line worked out
elsewhere, or a rule of thumb drawn over the data.
Adds a layer of areas: the band from 0 to each group's y along its x, for how much a series
holds over time, or from 0 to its x up its y with orientation: :y.
Adds a layer of bars counting the rows at each x. Each bar runs from 0 to the number of rows at
its x, or, where :weight is mapped, to the sum of their weights, and the y axis is titled
count. A row missing its x is not counted. The bars are drawn as geom_col/3 draws them.
Adds a layer of rectangles counting the rows in each, binning in two dimensions: the plane cut
into rectangles along x and y, and for each group a tile wherever a row falls, filled by
how many rows fall in it, or, where :weight is mapped, by the sum of their weights. A heatmap
of two continuous variables, it shows where many rows overlap, as points drawn over one another
cannot.
Adds a layer that draws nothing: its rows widen the axes, and the scale of any other aesthetic it maps, as a layer drawing them would, so a table of the values every plot of a set should reach gives them the same scales. A plot with no layers is drawn as though it had this one, taking the plot's mapping, so its axes span the mapped columns and are titled by them.
Adds a layer of box plots, a box for each group summarising its y: from its lower quartile to
its upper, a line across it at its median, and whiskers out to the least and greatest y within
coef: heights of the box beyond it, every value further out drawn as a point, an outlier. The
quartiles are R's default (type 7). Each box stands at the middle of its group's x values,
0.75 times the closest spacing of the x positions wide, counting from zero, 0.75 on a
discrete axis, or 0.9 of the
range of its group's x values where they are several, or as wide as its group's first mapped
:width, a number, or as width: says. A row missing its x or y, or at an infinite one, is
left out.
Adds a layer of bars, one per row, each from 0 to its y and centred on its x unless just:
says otherwise, for bars whose heights are in the data. Bars at the same x are stacked, those
below zero downward, the highest group at the bottom; with position: :dodge they are set side
by side within one bar's width, an x with one group keeping its whole width; with position: :dodge2, alone or with its options, bars whose spans overlap are set side by side, each its
share of their widths, with a gap between them.
Adds a layer of contour lines: for each group, the lines along which a surface, :z over a
grid of :x and :y, stands at each of a set of levels, as the lines on a map join places at
the same height. Every row is a corner of the grid, the grid each group's distinct x and y,
a place no row stands at missing, and a line runs between the grid's points, read linearly
along each side of each cell, at each level it crosses. Rows sharing a place are one, the last
kept; a row missing its x, y or z, or at an infinite one, is left out, and a line around a
missing place stays open. A grid laid at an angle is contoured square and turned back.
Adds a layer of contour bands: for each group, the regions where a surface, :z over a grid
of :x and :y, lies between each pair of consecutive levels, filled, as a map's bands of
height are. Each band holds the places at or past its low level and short of its high one; its
rings run round its edges, a band with holes having a ring round each, and are drawn as
geom_polygon/3 draws a shape of several rings. The grid, the rows it is read from and the
levels are geom_contour/3's: R's pretty() of the range of z over the whole layer unless
breaks:, bins: or binwidth: says otherwise, so faceted panels share their bands.
Adds a layer of points counting the rows at each place: one point for each combination of x,
y and the layer's other aesthetics that its rows hold, sized by how many rows hold it, or,
where :weight is mapped, by the sum of their weights, and the size legend titled n. The
points are drawn as geom_point/3 draws them.
Adds a layer of crossbars: a box for each row from its ymin to its ymax, with a line across
it at its y, for a value and the interval round it, or, turned, a box from its xmin to its
xmax with a line up it at its x.
Adds a layer of curves: a curved line for each row, from its x and y to its xend and
yend, for an arrow pointing at a mark or a link that should not cross the points between its
ends.
Adds a layer of densities: for each group, a smoothed estimate of how its rows are distributed
along x, a smoothed histogram drawn as a curve over the area beneath it, for a variable that
comes from a smooth distribution.
Adds a layer of a two-dimensional density's contour lines: for each group, a density of its
:x and :y estimated on a grid, as a smooth surface of where the rows lie thickest, and the
lines along which it stands at each of a set of levels, drawn as geom_contour/3 draws them.
The estimate is MASS's kde2d(): at each point of a grid, n: points along each axis across
the panel's range, the sum over the group's rows of a normal kernel along each axis, each a
quarter of its axis's bandwidth wide. Each bandwidth is h:, or else MASS's
bandwidth.nrd() of the group's rows, times adjust:. A row missing its x or y, or at
an infinite one, is left out; a panel where a bandwidth comes to no number above 0, as a group
of one row's does, is drawn empty.
Adds a layer of a two-dimensional density's contour bands: the estimate geom_density_2d/3
makes, banded between consecutive levels as geom_contour_filled/3 bands a surface, each band
filled by its level unless a fill is mapped or set.
Adds a layer of dots stacked over the bins of x, or of y with binaxis: :y, a dot plot: each
row a dot, as wide as its bin, stacked across the axis with the others in its bin, so the stacks
show how the values are spread. By dot density, the default, the bins fall where the data put
them: sorted along the axis, the first bin starts at the lowest value and runs binwidth: from
there, and each later one starts at the first value past the end of the one before, its dots
stacked halfway between its lowest and highest value; with method: :histodot the axis is cut
into fixed bins, as a histogram's are, each stack at its bin's middle. Every group in every
panel is binned on its own, unless binpositions: :all bins each panel's groups together.
Adds a layer of error bars: a vertical line for each row from its ymin to its ymax at its
x, with a whisker across each end, for an interval round a value, or, turned, a horizontal
one from its xmin to its xmax at its y.
Adds a layer of frequency polygons: the x axis cut into bins, as geom_histogram/3 cuts it,
and for each group a line through the middle of each bin at the number of rows in it, or, where
:weight is mapped, the sum of their weights. A bin of no rows is added at each end, so every
line starts and ends at 0. The y axis is titled count. The lines of different groups are drawn
over one another, not stacked, so a discrete colour compares the groups' distributions. A row
missing its x, or outside the breaks given, is not counted. The lines are drawn as
geom_path/3 draws paths.
Adds a layer drawing a function of x: its value at n: evenly spaced places along the x
axis, joined by a line, for a density, a fitted curve or a formula drawn over the data, or
alone on a plot with no data (new/0).
Adds a layer of hexagons counting the rows in each, hexagonal binning: the plane cut into
hexagons, each standing on a point, and for each group one hexagon wherever a row falls, filled
by how many rows fall in it, or, where :weight is mapped, by the sum of their weights. A
heatmap of two continuous variables, it shows where many rows overlap, as points drawn over
one another cannot.
Adds a layer of bars counting the rows in each bin, a histogram: the x axis cut into bins, and
for each group one bar per bin, from 0 to the number of rows in it, or, where :weight is
mapped, to the sum of their weights, a bin with no rows counting 0. The y axis is titled count.
The bins are 30 spanning each panel's x axis unless bins:, binwidth: or breaks: says
otherwise; bars of different groups in one bin are stacked. A row missing its x, or outside the
breaks given, is not counted. The bars are drawn as geom_col/3 draws them.
Adds a layer of horizontal reference lines: a line across the whole panel at each yintercept,
for a threshold, a target or a mean drawn over the data.
Adds a layer of points, as geom_point/3 adds, each moved a small random distance across and up
from its place, so that points sharing a place stand apart: by up to 0.4 of the closest spacing
of each panel's positions either way, 0.4 on a discrete axis, whose levels are 1 apart, unless
width: and height: say how far. The axes widen to hold the points where they land.
Adds a layer of labels: each row's label at its x and y, as geom_text/3 writes it, on a
box with rounded corners, so it reads over what lies beneath.
Adds a layer of lines: a line through each group's rows in order of their x, as a series over
time is drawn, or of their y with orientation: :y. Rows that share a position keep the order
the data gives them. Lines are drawn as geom_path/3 draws paths and take the same aesthetics.
Adds a layer of line ranges: a vertical line for each row from its ymin to its ymax at its
x, for an interval round a value, or a horizontal one from its xmin to its xmax at its
y.
Adds a layer of paths: a line through each group's rows in the order the data gives them, for a
line that may double back. geom_line/3 puts the rows in order first.
Adds a layer of points, one per row, at x and y, or each moved a small random distance from
there with position: :jitter, as geom_jitter/3 moves them.
Adds a layer of point ranges: a line range for each row, as geom_linerange/3 draws one, with
a point at its x and y on it, for a value and the interval round it, such as a mean and its
standard error.
Adds a layer of polygons: each group a shape through its rows in order, closed back to its
first, drawn in the look of its group's first row. A group whose rows carry a :subgroup is
one shape of several rings, one per subgroup, filled together by rule:, so a ring inside
another is a hole. A row missing its x or y is left out, and a layer of a single row draws
nothing.
Adds a layer of quantile-quantile points: for each group, its :sample sorted, each value
against the distribution's quantile at the same share of the way through it, so a sample drawn
from the distribution lies along a straight line and its departures show where the two differ.
The value ranked i of n is set against the quantile at (i - a) / (n + 1 - 2a), a 3/8 for a
group of 10 values or fewer and 1/2 past it.
Adds a layer of quantile-quantile lines: for each group, the line through two points, the
distribution's quantile against the :sample's at each of two probabilities, line_p:, the
quartiles unless given, so the points geom_qq/3 draws from the same sample lie along it where
the sample follows the distribution. Each line is drawn across the whole panel, as
geom_abline/3 draws one, from its slope and intercept; its two rows in the layer's table
hold its x and y at the least and greatest of the quantiles the points are set against, or
with fullrange: true across the x axis where some other layer maps it or the plot gives it a
scale, and they widen the axes to reach them.
Adds a layer of quantile lines: for each group, and for each of a set of quantiles, the line
that best follows that quantile of :y along :x, so that at the median half of the rows lie
above it and half below, as a box plot's middle line does at each place, and at 0.9 nine in
ten below. Each line is worked out at 100 places evenly spaced along the group's x, from its
least to its greatest, and each quantile's line is a group of its own.
Adds a layer of equal cells on a regular grid, one per row, drawn as one image: a faster, smaller tile for a surface of values, such as a density over two variables.
Adds a layer of rectangles, one per row, each from its xmin to its xmax and its ymin to its
ymax.
Adds a layer of ribbons: the band between each group's ymin and ymax along its x, for a
range around a line, or between its xmin and xmax up its y.
Adds a layer of rugs: a short line at the panel's edge for each row, at its x along the
bottom and at its y along the left, so the margins show how each axis's values are spread,
beside a scatter plot of the same rows. Every row is drawn, so rugs suit small tables.
Adds a layer of segments: a straight line for each row, from its x and y to its xend and
yend, for a line joining two points the data names apart, such as a span of time or a spike
down to an axis.
Adds a layer of smooths: a curve fitted to each group's rows, for the trend through a cloud of points, drawn over its band, the confidence interval around it.
Adds a layer of spokes: a straight line for each row, from its x and y, running radius in
the direction angle, for data that records a direction and a distance, such as wind or
movement.
Adds a layer of steps: a line through each group's rows in order of their x that moves in
stairs, changing one position at a time, so it shows exactly where each value changes, as a
count or a rate held until its next reading is drawn; or in order of their y with
orientation: :y. Rows that share a position keep the order the data gives them. Steps are
drawn as geom_path/3 draws paths, through the stairs, and take the same aesthetics.
Adds a layer of text: each row's label at its x and y.
Adds a layer of tiles, one per row, each a rectangle centred on its x and y, for a surface
or a grid of values drawn as colours.
Adds a layer of violins: for each group, a density of its y mirrored about its x, a compact
view of its distribution, drawn where a box plot would draw its box.
Adds a layer of vertical reference lines: a line up the whole panel at each xintercept, for
a date to mark, a threshold or a mean drawn over the data.
Sets the guide that reads each aesthetic's scale back: for an axis, :axis, ticks and labels
beside the panel, or {:axis, options}, one drawn as its options say, or :axis_logticks or
{:axis_logticks, options}, one with logarithmic ticks, or :axis_stack or {:axis_stack, options}, several one beyond the other, or for the angle round a radial panel's circle
:axis_theta or {:axis_theta, options}; for any other
aesthetic, :legend, a key for each break; :colorbar, a bar a continuous colour or fill
scale's colours run up; :colorsteps, a bar of one block of colour for each bin between a
colour or fill scale's breaks, all as long whatever the bins' widths, each break's label at its
edge; or {:legend, options}, a legend drawn as its options say; or :none for none, which
keeps an axis's title. The options are in "Guides" above.
Sets the plot's labels: the title of an axis or a legend, named by its aesthetic, the plot's
title, subtitle, caption and tag, and its alternative text, which Giggly.get_alt_text/1 reads.
Adds a layer of any stat and any geom, ggplot2's layer(): stat: and geom: each name one of
Giggly's by its function's name, as the layer functions' stat: and geom: do, or give a
module, a plugin's, adopting Giggly.Stat or Giggly.Geom.
The call takes the options the stat and the geom take, as a geom function given that stat
does, and is checked against both as Giggly's own layer functions check theirs. A plugin's own
layer function calls it with its stat and geom and its default position:; function:, the
name of that function as it would be written in a message ("MyPlugin.geom_ridgeline/3"),
makes each refusal name it, Plot.layer/3 where none is given.
A plot of data, with mapping applying to every layer.
The plot with data as its data, in place of any it had, so every layer drawing the plot's data
draws data; a layer with a table of its own keeps it.
Gives the plot a binned alpha scale, replacing any alpha scale it had.
Gives the plot a continuous alpha scale, replacing any alpha scale it had.
Gives the plot a date alpha scale, each date as opaque as it is far through the limits on
range:, replacing any alpha scale it had.
Gives the plot a date-time alpha scale, each date-time as opaque as it is far through the
limits on range:, replacing any alpha scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Gives the plot a discrete alpha scale, replacing any alpha scale it had.
Gives the plot an identity alpha scale, replacing any alpha scale it had: each value is drawn as
the opacity it is, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete alpha scale of the opacities given, replacing any alpha scale it had.
Gives the plot an alpha scale for ordered values, replacing any alpha scale it had: the scale
scale_alpha_discrete/2 gives, with its options.
Gives the plot a binned colour scale, replacing any colour scale it had: the values are cut into
bins at its breaks and every value in a bin takes one colour, by default the colour at the
bin's middle of the theme's palette_color_continuous: (theme/2), or else of a gradient from
#132B43 to #56B1F7, or a colour each of palette:, a palette's name or a list, given to the
bins in order.
Gives the plot a discrete colour scale from a ColorBrewer palette, replacing any colour scale it had.
Gives the plot a continuous colour scale, replacing any colour scale it had: the theme's
palette_color_continuous: (theme/2), or else a gradient from #132B43 to #56B1F7, as a
column of numbers gets by default, or through the colours of palette:, a palette's name or a
list, spaced evenly over the limits.
Gives the plot a date colour scale, a gradient from low: to high:, replacing any colour
scale it had.
Gives the plot a date-time colour scale, a gradient from low: to high:, replacing any
colour scale it had.
Gives the plot a discrete colour scale, replacing any colour scale it had: the theme's
palette_color_discrete: (theme/2), or else hues spaced evenly round the colour wheel, as a
discrete column gets by default, or the colours of palette:, a palette's name or a list, in
order.
Gives the plot a continuous colour scale, a gradient through a ColorBrewer palette, replacing any colour scale it had.
Gives the plot a binned colour scale from a ColorBrewer palette, replacing any colour scale it had.
Gives the plot a continuous colour scale diverging from mid: at midpoint:, toward low:
below it and high: above, replacing any colour scale it had.
Gives the plot a continuous colour scale, a gradient from low: to high:, replacing any colour
scale it had.
Gives the plot a continuous colour scale, a gradient through the colours of colors:, replacing
any colour scale it had.
Gives the plot a discrete colour scale of greys, replacing any colour scale it had.
Gives the plot a discrete colour scale of hues spaced evenly round the colour wheel, all of one chroma and luminance, replacing any colour scale it had.
Gives the plot an identity colour scale, replacing any colour scale it had: each value is drawn
as the colour it names, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete colour scale of the colours given, replacing any colour scale it had.
Gives the plot a colour scale for ordered values, replacing any colour scale it had: a viridis
palette's colours, as scale_color_viridis_d/2 gives them, or a blend through the colours of
type:.
Gives the plot a binned colour scale diverging from mid: at midpoint:, toward low: below
it and high: above, cut into steps, replacing any colour scale it had.
Gives the plot a binned colour scale, a gradient from low: to high: cut into steps, replacing
any colour scale it had.
Gives the plot a binned colour scale, a gradient through the colours of colors: cut into steps,
replacing any colour scale it had.
Gives the plot a binned colour scale from a viridis palette, replacing any colour scale it had.
Gives the plot a continuous colour scale, a gradient through a viridis palette, replacing any colour scale it had.
Gives the plot a discrete colour scale from a viridis palette, replacing any colour scale it had.
Gives the plot one continuous identity scale serving every aesthetic aesthetics names,
replacing any scale that served one of them: each value is drawn as the value it is, unscaled,
for each of the aesthetics alike; it draws no legend unless guide: asks for one.
Gives the plot one discrete identity scale serving every aesthetic aesthetics names,
replacing any scale that served one of them: each value is drawn as the value it is, unscaled,
for each of the aesthetics alike; it draws no legend unless guide: asks for one.
Gives the plot one manual scale serving every aesthetic aesthetics names, replacing any scale
that served one of them: its values are handed to the data's values by hand, as the manual
scale of each aesthetic hands them, for each of the aesthetics alike.
Gives the plot a binned fill scale, replacing any fill scale it had, as scale_color_binned/2
gives a colour scale.
Gives the plot a discrete fill scale from a ColorBrewer palette, replacing any fill scale it had,
as scale_color_brewer/2 gives a colour scale.
Gives the plot a continuous fill scale, replacing any fill scale it had, as
scale_color_continuous/2 gives a colour scale.
Gives the plot a date fill scale, a gradient from low: to high:, replacing any fill scale
it had, as scale_color_date/2 gives a colour scale.
Gives the plot a date-time fill scale, a gradient from low: to high:, replacing any fill
scale it had, as scale_color_datetime/2 gives a colour scale.
Gives the plot a discrete fill scale, replacing any fill scale it had, as
scale_color_discrete/2 gives a colour scale.
Gives the plot a continuous fill scale, a gradient through a ColorBrewer palette, replacing any
fill scale it had, as scale_color_distiller/2 gives a colour scale.
Gives the plot a binned fill scale, from a ColorBrewer palette, replacing any fill scale it had, as
scale_color_fermenter/2 gives a colour scale.
Gives the plot a continuous fill scale diverging from mid: at midpoint:, replacing any fill
scale it had, as scale_color_gradient2/2 gives a colour scale.
Gives the plot a continuous fill scale, a gradient from low: to high:, replacing any fill
scale it had, as scale_color_gradient/2 gives a colour scale.
Gives the plot a continuous fill scale, a gradient through the colours of colors:, replacing
any fill scale it had, as scale_color_gradientn/2 gives a colour scale.
Gives the plot a discrete fill scale of greys, replacing any fill scale it had, as
scale_color_gray/2 gives a colour scale.
Gives the plot a discrete fill scale of hues spaced evenly round the colour wheel, replacing any
fill scale it had, as scale_color_hue/2 gives a colour scale.
Gives the plot an identity fill scale, replacing any fill scale it had: each value is drawn as
the colour it names, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete fill scale of the colours given, replacing any fill scale it had, as
scale_color_manual/2 gives a colour scale.
Gives the plot a fill scale for ordered values, replacing any fill scale it had, as
scale_color_ordinal/2 gives a colour scale.
Gives the plot a binned fill scale, diverging from mid: at midpoint:, cut into steps, replacing any fill scale it had, as
scale_color_steps2/2 gives a colour scale.
Gives the plot a binned fill scale, a gradient cut into steps, replacing any fill scale it had, as
scale_color_steps/2 gives a colour scale.
Gives the plot a binned fill scale, a gradient through colors: cut into steps, replacing any fill scale it had, as
scale_color_stepsn/2 gives a colour scale.
Gives the plot a binned fill scale, from a viridis palette, replacing any fill scale it had, as
scale_color_viridis_b/2 gives a colour scale.
Gives the plot a continuous fill scale, a gradient through a viridis palette, replacing any fill
scale it had, as scale_color_viridis_c/2 gives a colour scale.
Gives the plot a discrete fill scale from a viridis palette, replacing any fill scale it had, as
scale_color_viridis_d/2 gives a colour scale.
Gives the plot a binned line type scale, replacing any line type scale it had.
Gives the plot a discrete line type scale, replacing any line type scale it had.
Gives the plot an identity line type scale, replacing any line type scale it had: each value is
drawn as the line type it names, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete line type scale of the line types given, replacing any line type scale it had.
Gives the plot a binned line width scale, replacing any line width scale it had.
Gives the plot a continuous line width scale, replacing any line width scale it had.
Gives the plot a date line width scale, each date's width as far through the limits as the
date is, on range:, replacing any line width scale it had.
Gives the plot a date-time line width scale, each date-time's width as far through the limits
as it is, on range:, replacing any line width scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Gives the plot a discrete line width scale, replacing any line width scale it had.
Gives the plot an identity line width scale, replacing any line width scale it had: each value
is drawn as the width it is, in millimetres, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete line width scale of the widths given, replacing any line width scale it had.
Gives the plot a line width scale for ordered values, replacing any line width scale it had:
the scale scale_linewidth_discrete/2 gives, with its options.
Gives the plot a continuous size scale by width, replacing any size scale it had.
Gives the plot a binned shape scale, replacing any shape scale it had.
Gives the plot a discrete shape scale, replacing any shape scale it had.
Gives the plot an identity shape scale, replacing any shape scale it had: each value is drawn as
the shape it names, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete shape scale of the shapes given, replacing any shape scale it had.
Gives the plot a continuous size scale that draws 0 at size 0, replacing any size scale it had.
Gives the plot a binned size scale, replacing any size scale it had.
Gives the plot a binned size scale that draws 0 at size 0, replacing any size scale it had.
Gives the plot a continuous size scale, replacing any size scale it had.
Gives the plot a date size scale, each date's area as far through the limits as the date is,
on range:, replacing any size scale it had.
Gives the plot a date-time size scale, each date-time's area as far through the limits as it
is, on range:, replacing any size scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Gives the plot a discrete size scale, replacing any size scale it had.
Gives the plot an identity size scale, replacing any size scale it had: each value is drawn as
the size it is, in millimetres, unscaled; it draws no legend unless guide: asks for one.
Gives the plot a discrete size scale of the sizes given, replacing any size scale it had.
Gives the plot a size scale for ordered values, replacing any size scale it had: the scale
scale_size_discrete/2 gives, with its options.
Gives the plot a binned x scale, replacing any x scale it had.
Gives the plot a continuous x scale with the given options, replacing any x scale it had.
Gives the plot a date x scale with the given options, replacing any x scale it had.
Gives the plot a date-time x scale with the given options, replacing any x scale it had.
Gives the plot a discrete x scale with the given options, replacing any x scale it had.
Gives the plot a continuous x scale through a base-10 logarithm, replacing any x scale it had,
as scale_x_continuous(plot, transform: :log10) does: each value is placed at its logarithm,
and the axis marked at powers of ten, or at multiples of them where too few powers fall on it,
and labelled in data units. Zero is placed at minus infinity, the panel's edge, and a negative
value is missing.
Gives the plot a continuous x scale running from high to low, replacing any x scale it had, as
scale_x_continuous(plot, transform: :reverse) does: each value is placed at its negation, and
the axis marked and labelled in data units.
Gives the plot a continuous x scale through a square root, replacing any x scale it had, as
scale_x_continuous(plot, transform: :sqrt) does: each value is placed at its square root, and
the axis marked and labelled in data units. A negative value is missing.
Gives the plot a time x scale with the given options, replacing any x scale it had.
Gives the plot a binned y scale, replacing any y scale it had, as scale_x_binned/2 gives an x
scale.
Gives the plot a continuous y scale with the given options, replacing any y scale it had, as
scale_x_continuous/2 gives an x scale.
Gives the plot a date y scale with the given options, replacing any y scale it had, as
scale_x_date/2 gives an x scale.
Gives the plot a date-time y scale with the given options, replacing any y scale it had, as
scale_x_datetime/2 gives an x scale.
Gives the plot a discrete y scale with the given options, replacing any y scale it had, as
scale_x_discrete/2 gives an x scale.
Gives the plot a continuous y scale through a base-10 logarithm, replacing any y scale it had,
as scale_x_log10/2 gives an x scale.
Gives the plot a continuous y scale running from high to low, replacing any y scale it had, as
scale_x_reverse/2 gives an x scale.
Gives the plot a continuous y scale through a square root, replacing any y scale it had, as
scale_x_sqrt/2 gives an x scale.
Gives the plot a time y scale with the given options, replacing any y scale it had, as
scale_x_time/2 gives an x scale.
Adds the layer geom_histogram/3 adds, bars counting the rows in each bin, from the same mapping
and options, but that a glyph its legend's keys borrow draws its own corners, where
geom_histogram/3's draws pointed ones.
Adds the layer geom_bin_2d/3 adds, tiles counting the rows in each rectangle, from the same
mapping and options, but that a glyph its legend's keys borrow draws its own corners, where
geom_bin_2d/3's draws pointed ones.
Adds the layer geom_hex/3 adds, hexagons counting the rows in each, from the same mapping and
options, but that linejoin: takes no default: the hexagons' corners are pointed, and a
legend's keys draw their glyph's own unless it is given.
Adds a layer of connections: for each group, its rows in order of x, each joined to the next
by a path of the shape connection: gives, so a series can be drawn as steps, as steps
halfway between its rows, or by any shape of one's own. The default steps across to the next
row's x and then up to its y, as a quantity that holds until it changes is drawn.
Adds the layer geom_contour/3 adds, contour lines through :z over a grid of :x and :y,
from the same mapping and options, but that linejoin: takes no default: the lines' corners
are rounded, and a legend's keys draw their glyph's own unless it is given.
Adds the layer geom_contour_filled/3 adds, contour bands through :z over a grid of :x and
:y, from the same mapping and options, but that linejoin: takes no default: the bands'
corners are rounded, and a legend's keys draw their glyph's own unless it is given, pointed for
a band's own.
Adds a layer of densities, each the same estimate geom_density/3 makes, drawn as areas
(geom_area/3): filled with the theme's ink mixed 20% toward its paper and unoutlined unless a
colour is mapped or set, and piled on one another unless position: :identity draws each where
it is. It takes geom_density/3's options, and computes and refuses what it does.
Adds the layer geom_density_2d/3 adds, a two-dimensional density of :x and :y, drawn with
its contour lines unless geom: names another geom, most often with contour: false, a mark
at each point of the grid: :point points, :raster a raster's cells, :tile tiles. A geom
given with contouring left on draws the contour lines' points.
Adds the layer geom_density_2d_filled/3 adds, a two-dimensional density's contour bands, from
the same mapping and options, drawn with polygons unless geom: names another geom, which
takes the options of its own function. Its position: is :identity unless given.
Adds a layer of empirical cumulative distributions: for each group, the share of its rows at or
below each value of x, drawn as steps (geom_step/3) that climb from 0 to 1, rising at each
value by its rows' share, so the whole distribution is read without binning or smoothing it.
Where a :weight is mapped, the share is of the group's weights, each row counting by its own.
Adds a layer of data ellipses: for each group, the outline of the ellipse a distribution
fitted to its x and y expects to hold level: of its points, so its centre shows where the
group sits, its size how widely it spreads, and its tilt how x and y move together. The
fit is a multivariate t distribution of 5 degrees of freedom unless type: says otherwise,
which outlying points pull on less than on a normal one, and each outline runs segments:
even steps around its centre, its first place repeated last.
Adds the layer geom_function/3 adds, a function of x, from the same mapping and options.
Adds a layer drawing a table's rows as they are, its stat the identity, ggplot2's
stat_identity(): points unless geom: names another geom, which takes the options of its own
function. It is the layer every geom function whose stat is the identity adds, drawn with the geom
geom: names.
Adds a layer computed by a function of your own: for each group in each panel, fun: is handed
the group's rows and returns the rows to draw, so any computation a layer needs, a convex hull,
each group's centre, a line from each point to it, is a function away. It draws points unless
geom: names another geom; stat: :manual gives any geom function the same stat, with its
fun:.
Adds the layer geom_qq/3 adds, quantile-quantile points, from the same mapping and options.
Adds the layer geom_qq_line/3 adds, quantile-quantile lines, from the same mapping and
options.
Adds the layer geom_quantile/3 adds, quantile lines of :y along :x, from the same mapping
and options, but that linejoin: takes no default: the lines' corners are rounded, and a
legend's keys draw their glyph's own unless it is given.
Adds a layer of smooths, as geom_smooth/3 does: the same curves, options and refusals.
Adds the layer geom_count/3 adds, points counting the rows at each place, from the same
mapping and options.
Adds a layer summarising the y values at each x: for each group, a row at each of its x
positions, its y a summary of the values there and its ymin and ymax an interval round
it, drawn as point ranges unless geom: says otherwise. Given no summary, it is the mean less
and plus one standard error, which a position holding one value has no interval for. A row
missing its x or y, or at an infinite one, is left out.
Adds a layer of rectangles each summarising a third variable, :z, over the rows in it: the
plane cut into rectangles along x and y, as geom_bin_2d/3 cuts it, and for each group a
tile wherever a row falls, filled by the mean of the z of its rows, or the summary fun:
gives. A heatmap of how a value varies over two others.
Adds a layer summarising the y values in bins of x: the x axis cut into bins, as
stat_bin/3 cuts it, and for each group a row at each bin some of its rows fall in, its x the
bin's middle, its y a summary of the values there and its ymin and ymax an interval round
it, drawn as point ranges unless geom: says otherwise, each as wide as its bin. It is
stat_summary/3 over bins, for a summary of many rows whose x values rarely repeat.
Adds a layer of hexagons each summarising a third variable, :z, over the rows in it: the
plane cut into hexagons, as geom_hex/3 cuts it, and for each group a hexagon wherever a row
falls, filled by the mean of the z of its rows, or the summary fun: gives. A heatmap of how
a value varies over two others.
Adds a layer drawing each distinct row once: within each panel, every row that repeats an
earlier one in all its columns, its positions, its other aesthetics and its group, is left out,
so marks that would fall exactly on one another are drawn once. Two values are alike where they
are equal, a missing value alike to a missing one; the rows kept are the first of each, in their
order, panel by panel. It draws points unless geom: names another geom; stat: :unique gives
any geom function the same stat.
Adds a layer of violins, the same layer geom_violin/3 adds: each group's densities along y,
drawn as a violin. It takes geom_violin/3's options, and computes and refuses what it does.
Changes the look everything but the marks is drawn in: its backgrounds, grid lines, axes, strips, legends and titles, each an element of the theme, set by name.
Draws everything but the marks dark on light: a white panel bordered in dark grey, with light grey grid lines, and light grey strips bordered as the panel is.
Draws the axes as lines, with no grid: black axis lines with square ends, black ticks and tick labels, no border round the panel, and white strips bordered in black.
Draws everything but the marks on a dark panel: a mid-grey panel, and legend keys, with darker grid lines half as wide as a line, the minor ones a quarter, thin dark grey ticks, and near-black strips with near-white labels.
Draws everything but the marks in the default theme, in the colours and at the base sizes given: a grey panel with white grid lines, the minor ones half as wide, dark grey ticks, grey tick labels, and light grey strips, each grey the ink mixed toward the paper.
Draws everything but the marks in light grey lines on white: a white panel bordered in light grey, lighter grey grid lines half as wide as a line, the minor ones a quarter, light grey ticks, and light grey strips with white labels.
Draws everything but the marks in black lines of various widths on white: a white panel bordered in black, black grid lines a tenth of a line wide, the minor ones a twentieth, black ticks and tick labels, and black strips with white labels.
Draws nothing behind the marks but their grid lines: no panel background, border or ticks, the tick labels further from the panel in their stead, no background to the strips, the legends or their keys, and a white plot background with no border.
Sets the elements of every axis by shorter names: text: sets axis_text, every axis's tick
labels.
Sets the elements of the x axis below the panels by shorter names: text: sets
axis_text_x_bottom.
Sets the elements of the y axis left of the panels by shorter names: text: sets
axis_text_y_left.
Sets the elements of the y axis right of the panels by shorter names: text: sets
axis_text_y_right.
Sets the elements of the x axis above the panels by shorter names: text: sets
axis_text_x_top.
Sets the elements of both x axes, below and above the panels, by shorter names: text: sets
axis_text_x.
Sets the elements of both y axes, left and right of the panels, by shorter names: text: sets
axis_text_y.
Sets the elements of the legends by shorter names: key_size: sets legend_key_size.
Sets the elements of the panels by shorter names: grid_minor: sets panel_grid_minor.
Sets the elements of the whole plot by shorter names: title: sets plot_title.
Sets the elements of the facets' strips by shorter names: text_x: sets strip_text_x.
Draws as theme_bw/2 does but with no grid lines and no margin inside a legend, and sets a
radial panel's radius labels as the y axis's: a theme meant for comparing drawings, which
should not change from one version to the next.
Draws nothing but the marks, the legends, the strips' labels and the plot's titles: no axes, grid lines or backgrounds, on a transparent plot with no margin round it. With no lines and no borders to draw, only its base size changes what it draws.
Gives the plot a discrete x scale showing values, in the order given, replacing any x scale it
had, as scale_x_discrete(plot, limits: values) does.
Gives the plot an x scale from low to high, replacing any x scale it had: a continuous scale
for numbers, as scale_x_continuous(plot, limits: {low, high}) gives, a date scale for dates,
as scale_x_date(plot, limits: {low, high}) gives, or a date-time scale for date-times, as
scale_x_datetime(plot, limits: {low, high}) gives; nil leaves an end to the data. Numbers
given high to low run the axis from high to low, as transform: :reverse runs it, each value
placed at its negation; dates and date-times given so name the same axis as low to high. A
discrete axis's limits are a list of its values, which xlim/2 takes. Two times of day are
refused: scale_x_time(plot, limits: {low, high}) takes them.
Gives the plot a discrete y scale showing values, in the order given, replacing any y scale it
had, as xlim/2 gives an x scale.
Gives the plot a y scale from low to high, replacing any y scale it had, as xlim/3 gives
an x scale.
Types
@type aesthetic() :: atom()
An aesthetic's name, such as :x, :y or :color.
@type axis_end() :: number() | Date.t() | DateTime.t() | NaiveDateTime.t() | nil
An end of an axis's limits: a number, a date or a date-time, or nil for the data's.
A column of a table as written: its name as an atom or a string.
@type coord() :: struct()
How positions are placed in each panel: a coordinate system's struct.
@type facet() :: struct()
How the plot's rows are split into panels: a facet's struct.
@type facet_argument() :: Giggly.Mapping.value() | {column_reference(), Giggly.Mapping.value()}
A facet as written: what a mapping maps an aesthetic to, named by its text, or {name, value},
the value named by an atom or a string.
@type guide() :: :none | :axis | :axis_logticks | :axis_theta | :axis_stack | :legend | :colorbar | :colorsteps | :bins | struct()
The guide that reads an aesthetic's scale back: :axis, :axis_logticks, :axis_theta,
:axis_stack, :legend, :colorbar, :colorsteps, :bins, :none for none, or the axis or
legend {:axis, options}, {:axis_logticks, options}, {:axis_theta, options},
{:axis_stack, options}, {:legend, options} or another guide's options make, as the plot
records it.
The guides guides/2 sets, by aesthetic, each winning over its scale's own.
The labels labs/2 sets, by what each titles: an aesthetic's guide, or the plot's :title,
:subtitle, :caption or :tag; each its text, or :none for none; and its :alt text,
which may also be a function of the plot.
@type mapping() :: Giggly.Mapping.t()
A mapping as stored: aesthetic to its value resolved, each column it reads named as a string, in the table the layer draws.
@type mapping_argument() :: %{optional(aesthetic()) => Giggly.Mapping.value()}
A mapping as written: aesthetic to a column, an expression or a constant.
The scales the plot sets, by aesthetic: each a scale's struct, as yet untrained.
@type t() :: %Giggly.Plot{ coord: coord(), data: Giggly.DataFrame.t() | :none, facet: facet(), guides: guides(), labels: labels(), mapping: mapping(), reversed_layers: [struct()], scales: scales(), theme: theme() }
A plot: its data, :none for none, its mapping, its facet, coordinate system, scales, the guides guides/2
sets, its theme, the labels labs/2 sets, and its layers newest first (each function adds one at the front; they are
assembled in the order they were added).
@type theme() :: %{ complete: %{ name: :gray | :bw | :linedraw | :light | :dark | :minimal | :classic | :test | :void, ink: String.t(), paper: String.t(), accent: String.t(), base_size: float(), base_line_size: float(), base_rect_size: float(), base_family: String.t(), header_family: String.t() | :none } | :none, settings: %{optional(atom()) => term()} }
The look everything but the marks is drawn in, a plot's or one kept apart from any: the
complete theme a theme_* function chose, by name with its colours, base sizes and families,
:none for a header family not given, or :none for none, which draws the plot in theme_gray/2's
at its defaults, and the settings theme/2 has laid over it, by element, a line's, a
rectangle's or a text's properties as a map, {:replace, properties} where it replaces the
element whole, and :none where it is removed.
Functions
@spec aes(t(), mapping_argument()) :: t()
The plot with mapping added to its mapping: each aesthetic mapping maps replaces the plot's
mapping of it, one it maps to :none removed, and the plot's others are kept.
mapping takes the values new/2's does, raising alike, and its columns are checked by the
layers that use them when the plot is run, so it may come after them.
iex> plot =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8], "cyl" => ["6", "4"]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.aes(%{y: :wt, colour: :cyl})
iex> plot.mapping
%{x: "wt", y: "wt", color: "cyl"}
Adds an annotation: a layer drawn from values given here rather than from the data's columns,
for a label, a shaded rectangle or a line placed by hand. geom names what draws it: :blank,
:point, :col or :bar, :path, :line, :segment, :curve, :spoke, :rug,
:linerange, :pointrange, :errorbar, :crossbar, :text, :label or :rect.
An annotation's positions widen the axes as the data's do. It takes nothing from the plot's
mapping, titles no axis, is in no legend, and under a facet is drawn in every panel. It is drawn
where it is placed: text and labels are not nudged, and bars at one x are not stacked.
Each option takes one value, or a list of them, one per annotation: every list holds as many
values as the others, and a single value is used for every annotation, so
x: [2, 3, 4, 5], y: 25 places four. A position is a number, :infinity or :neg_infinity,
which reach the panel's edge, nil for none, a string on a discrete axis, true or false, or
a date, a date-time or a time on such an axis. Of the other options, label:, colour:,
alpha: and fill: each take a list, its values of one type, and so do a point's or a point
range's shape:, size: and stroke:, a text's or a label's size:, angle:, hjust:,
vjust:, family:, fontface: and lineheight:, a spoke's angle: and radius:, a bar's, a segment's, a
curve's, a spoke's, a rug's, a range's,
a label's or a rectangle's linewidth: and linetype:, whose list holds line types, a dash
pattern among them a tuple, and a path's or a line's linewidth:, a line whose width changes along it drawn a segment from each annotation
to the next; the rest take one value, a label's label_padding: one for every label however
many sides it gives. Under a facet that makes more than one panel, an annotation given such a
list raises when the plot is run.
Each geom takes the positions it draws at and the options its own function takes but data:
and position:, and geom_text/3's nudging:
:blank, drawing nothing, so its positions widen the axes alone:x:,y:,xmin:,xmax:,xend:,ymin:,ymax:andyend:;:point:x:,y:,alpha:,colour:,fill:,shape:,size:andstroke:;:coland:bar, each a bar from 0 to itsyasgeom_col/3draws one:x:,y:,alpha:,colour:,fill:,linewidth:,linetype:,width:andjust:;:path:x:,y:,alpha:,colour:,linewidth:,linetype:,lineend:,linejoin:,linemitre:andarrow:, and:linethose andorientation:;:segment:x:,y:,xend:,yend:,alpha:,colour:,linewidth:,linetype:,lineend:,linejoin:andarrow:;:curve:x:,y:,xend:,yend:,alpha:,colour:,linewidth:,linetype:,lineend:,arrow:,curvature:,angle:andncp:;:spoke, a segment fromx:andy:runningradius:in the directionangle:, in radians: those andalpha:,colour:,linewidth:,linetype:,lineend:,linejoin:andarrow:;:rug:x:,y:,alpha:,colour:,linewidth:,linetype:,sides:,length:,outside:andlineend:;:linerange:x:,y:,xmin:,xmax:,ymin:,ymax:,orientation:,alpha:,colour:,linewidth:,linetype:andlineend:, and:pointrangethose andfill:,shape:,size:andstroke:;:errorbar: a line range's options andwidth:, one value or a list;:crossbar:x:,y:,xmin:,xmax:,ymin:,ymax:,orientation:,width:,alpha:,colour:,fill:,linewidth:,linetype:,lineend:,linejoin:and themiddle_andbox_looks, itswidth:one value or a list;:text:x:,y:,label:,check_overlap:,size_unit:,alpha:,colour:,size:,angle:,hjust:,vjust:,family:,fontface:andlineheight:;:label:x:,y:,label:,size_unit:,alpha:,colour:,fill:,linewidth:,linetype:,size:,angle:,hjust:,vjust:,family:,fontface:,lineheight:,label_padding:,label_r:,border_colour:andtext_colour:;:rect:xmin:,xmax:,ymin:,ymax:,alpha:,colour:,fill:,linewidth:andlinetype:.
The reference lines are not among them: each annotates on its own, given its lines as values
(geom_hline/3, geom_vline/3, geom_abline/3).
A text or label annotation's label: may be a label another library lays out, such as maths, a
struct implementing Giggly.Label, or a list of them, one per annotation. Each is laid out in
its annotation's size, colour, alpha, family and face, turned by its angle:, and justified by
its whole box, vjust: 0 setting the bottom of its glyphs on its place and 1 hanging their
top from it. A label annotation's box is the label's own, padded on every side, justified whole
and filled, bordered and rounded as a string's is, and its label set in text_colour: or the
annotation's colour. Such labels take no lineheight:, since their lines break where their
own markup breaks them, and no :symbol face.
Raises ArgumentError for a geom it does not draw with, for lists of different lengths, for a
list whose values are not of one type, and for an aesthetic the geom needs and is not given, a
range's three positions among them, as geom_linerange/3 refuses them, and for labels another
library lays out given beside strings, or with a lineheight: or a :symbol face;
NimbleOptions.ValidationError for an option the geom does not take, or a value it cannot
draw.
iex> frame =
...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.annotate(:text, x: [2.0, 3.0], y: 25.0, label: ["my label", "label 2"])
...> |> Giggly.layer_data(1)
iex> {Giggly.DataFrame.pull(frame, :y), Giggly.DataFrame.pull(frame, :label)}
{[25.0, 25.0], ["my label", "label 2"]}
Adds a custom annotation: SVG markup of your own, or a plot, drawn over a rectangle placed by
its corners, from xmin: to xmax: across and from ymin: to ymax: up, the same drawing in
every panel. A corner not given is the panel's edge, so given none it fills the panel.
drawing is markup, a string, or a plot. Markup is written into the drawing as it is, never
read or checked. Its coordinates are points from the rectangle's top left, and a root <svg>
with only a viewBox is scaled to fill the rectangle; it may draw past the rectangle's edges,
and is cut at the panel's edge where the panel clips.
A plot is drawn when this plot is, laid out at the rectangle's size as it would be laid out as
a drawing of that size: its text, points and lines keep their sizes and its panels take what
is left, so a small rectangle leaves its panels little room. A plot that keeps its panels'
proportions, as coord_fixed/2 does, keeps them, centred in the rectangle. Each part of it is
cut off as it would be in a drawing of its own, its panels at their edges and its axes and
titles nowhere, never at this plot's panel, so where the rectangle reaches past the panel the
plot is drawn past it too. A plot that cannot be drawn raises when this one is drawn.
Its corners are placed as annotation_raster/3's are. They do not widen the axes, so it is
drawn where the axes the other layers give put it, and the scales' limits never cut it. A
corner is a position on its axis, put through the axis's scale, so under a logarithmic scale it
is given in the data's units, on a discrete axis it may be a level, and under a date scale a
date; :infinity and :neg_infinity reach the panel's edges. The rectangle runs from the
lesser to the greater of each pair, whichever way its corners, the scale or the axis run. A
corner the scale cannot place, such as a negative one under a logarithm, draws nothing.
It takes nothing from the plot's mapping, titles no axis and is in no legend. It draws only in
Cartesian coordinates, coord_cartesian/2 and coord_fixed/2: drawing it under another raises
ArgumentError, though Giggly.layer_data/2 still shows its corners.
Raises NimbleOptions.ValidationError for a corner that is not a position.
Options
:xmin- The drawing's left edge, in the units of the x axis: a number,:infinityor:neg_infinity, which reach the panel's edge, a string on a discrete axis,trueorfalse, or a date, a date-time or a time on such an axis. The default value is:neg_infinity.:xmax- The drawing's right edge, asxmin:gives one. The default value is:infinity.:ymin- The drawing's bottom edge, in the units of the y axis, asxmin:gives one. The default value is:neg_infinity.:ymax- The drawing's top edge, asymin:gives one. The default value is:infinity.iex> svg = ...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.annotation_custom(~s(<circle r="5"/>), xmin: 2.8, xmax: 3.2) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> svg =~ ~s(<circle r="5"/>) true
A plot drawn in the top right of another, its three points circles:
iex> data = %{"wt" => [2.62, 2.88, 3.44], "mpg" => [21.0, 22.8, 18.7]}
iex> inset = data |> Giggly.Plot.new(%{x: :wt, y: :mpg}) |> Giggly.Plot.geom_point()
iex> svg =
...> data
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_line()
...> |> Giggly.Plot.annotation_custom(inset, xmin: 3.0, ymin: 21.0)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> length(Regex.scan(~r/<circle /, svg))
3
Adds a raster annotation: an image, given as a grid of colours, stretched over a rectangle placed
by its corners, from xmin: to xmax: across and from ymin: to ymax: up, the same image in
every panel. It is drawn faster and smaller than the tiles geom_raster/3 would draw for it.
raster is the image's cells row by row, the top row first and each row from the left, every
row as long: each cell a colour, as a name such as "steelblue", a hex colour such as
"#4682B4" or, with an alpha of its own, "#4682B480", "transparent", or :none, a cell left
clear. The colours are drawn as given, never through a scale.
Its corners do not widen the axes, so it is drawn where the axes the other layers give put it,
and the scales' limits never cut it: an image reaching past the panel is cut at the panel's edge
where the panel clips. A corner is a position on its axis, put through the axis's scale, so
under a logarithmic scale it is given in the data's units, on a discrete axis it may be a level,
and under a date scale a date; :infinity and :neg_infinity reach the panel's edges, so
xmin: :neg_infinity, xmax: :infinity, ymin: :neg_infinity, ymax: :infinity fills the panel.
The image is drawn the right way up whichever way its corners, the scale or the axis run. A
corner the scale cannot place, such as a negative one under a logarithm, draws no image.
It takes nothing from the plot's mapping, titles no axis and is in no legend. It draws only in
Cartesian coordinates, coord_cartesian/2 and coord_fixed/2: drawing it under another raises
ArgumentError, though Giggly.layer_data/2 still shows its corners.
Raises ArgumentError for a raster that is not a list of rows of colours, all as long, or for
a cell that is not a colour, naming its row and column; NimbleOptions.ValidationError for a
missing corner, or one that is not a position.
Options
:xmin- Required. The image's left edge, in the units of the x axis: a number,:infinityor:neg_infinity, which reach the panel's edge, a string on a discrete axis,trueorfalse, or a date, a date-time or a time on such an axis.:xmax- Required. The image's right edge, asxmin:gives one.:ymin- Required. The image's bottom edge, in the units of the y axis, asxmin:gives one.:ymax- Required. The image's top edge, asymin:gives one.:interpolate(boolean/0) - Whether a viewer blends neighbouring cells' colours, smoothing the image, rather than drawing each cell as a block of its colour. The default value isfalse.iex> frame = ...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.annotation_raster([["red", "blue"], ["#00FF0080", :none]], ...> xmin: 2.8, ...> xmax: 3.2, ...> ymin: :neg_infinity, ...> ymax: :infinity ...> ) ...> |> Giggly.layer_data(1) iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :ymax)} {[2.8], [:infinity]}
Draws the plot in cartesian coordinates, x across each panel and y up it, replacing any
coordinate system the plot had. A plot is cartesian until another is chosen, each panel cut off
at its edges; with clip: :off what is drawn may run past them, as rugs drawn outside the
panel do.
xlim: and ylim: zoom an axis without changing the data: every row reaches the stats, a
smooth's curve is fitted to all of them, and a mark past the zoomed extent is cut off at the
panel's edge, where a scale's limits: leave out the rows outside them. The extent is still
widened by the scale's expansion unless expand: says otherwise, and its breaks are the
scale's on it. A limit of a type the axis's scale does not take, a date on a continuous axis or
a number on a date one, is refused when the plot is run.
ratio: fixes each panel's shape, as coord_fixed/2 does; a facet freeing an axis's scales is
then refused when the plot is run, since every panel takes the first one's shape, unless
facet_grid/2's space: :free sizes every panel by its scales' lengths.
Options
:xlim- The x axis's extent to zoom to,{low, high}in data units: two numbers, two dates, two date-times or two times of day, as the axis's scale takes them, a discrete axis's as positions, its first value at 1, andnilfor an end the scale decides; in either order. The data is unchanged, every row reaching the stats, and a mark past the extent is cut off at the panel's edge, where a scale's limits leave out the rows outside them. The default value is{nil, nil}.:ylim- The y axis's extent to zoom to, asxlim:gives x's. The default value is{nil, nil}.:expand- Whether each axis's extent is widened by its scale's expansion (true), or is exactly its limits, the scale's orxlim:andylim:, (false); or a keyword list of the panel's sides,:top,:right,:bottomand:left, eachtrueorfalse, a side left out widened. The default value istrue.:ratio- How many times as long on the page a unit of y is as a unit of x, 0 or more, which fixes each panel's shape whatever the drawing's size; 0 draws the panel no taller than a line. A facet freeing either axis's scales cannot be drawn with one.:none, when not given, lets each panel take the shape the drawing leaves it. The default value is:none.:reverse- Which axes run from their high end to their low end::x,:y, both (:xy) or neither (:none). The scales and their breaks are as they were, and the axes stay below and left of each panel. The default value is:none.:clip- Whether what is drawn in each panel is cut off at its edges (:on), or may run past them (:off). The default value is:on.
Clipped, the panel's cell has a clip path of its own beside the plot's background's; unclipped, the background's alone:
iex> plot =
...> %{"wt" => [2.32, 2.62, 3.44], "mpg" => [22.8, 21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_rug(outside: true)
iex> Enum.map([:on, :off], fn clip ->
...> svg =
...> plot
...> |> Giggly.Plot.coord_cartesian(clip: clip)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
...>
...> ~r/<clipPath/ |> Regex.scan(svg) |> length()
...> end)
[2, 1]Zoomed to 2.5 to 3.5, the points keep their rows, and the x axis is labelled across the zoomed extent, 3.50 included:
iex> plot =
...> %{"wt" => [2.32, 2.62, 3.44], "mpg" => [22.8, 21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.coord_cartesian(xlim: {2.5, 3.5})
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[2.32, 2.62, 3.44]
iex> svg = plot |> Giggly.to_svg() |> IO.iodata_to_binary()
iex> ~r{>(\d\.\d\d)</text>} |> Regex.scan(svg, capture: :all_but_first) |> List.flatten()
["2.50", "2.75", "3.00", "3.25", "3.50"]
Draws the plot in cartesian coordinates whose units keep a fixed ratio on the page, replacing any
coordinate system the plot had: a unit of y is ratio: times as long as a unit of x, 1 unless
given, so each panel's shape follows its extents whatever the drawing's size, as
coord_cartesian/2 draws it given ratio:. It takes every option coord_cartesian/2 takes.
Every panel takes the first one's shape, so a facet freeing either axis's scales is refused
when the plot is run, unless facet_grid/2's space: :free sizes every panel by its scales'
lengths, a unit as long in every panel.
Options
:xlim- The x axis's extent to zoom to,{low, high}in data units: two numbers, two dates, two date-times or two times of day, as the axis's scale takes them, a discrete axis's as positions, its first value at 1, andnilfor an end the scale decides; in either order. The data is unchanged, every row reaching the stats, and a mark past the extent is cut off at the panel's edge, where a scale's limits leave out the rows outside them. The default value is{nil, nil}.:ylim- The y axis's extent to zoom to, asxlim:gives x's. The default value is{nil, nil}.:expand- Whether each axis's extent is widened by its scale's expansion (true), or is exactly its limits, the scale's orxlim:andylim:, (false); or a keyword list of the panel's sides,:top,:right,:bottomand:left, eachtrueorfalse, a side left out widened. The default value istrue.:ratio- How many times as long on the page a unit of y is as a unit of x, 0 or more; 1, a unit as long on both axes, unless given. The default value is1.0.:reverse- Which axes run from their high end to their low end::x,:y, both (:xy) or neither (:none). The scales and their breaks are as they were, and the axes stay below and left of each panel. The default value is:none.:clip- Whether what is drawn in each panel is cut off at its edges (:on), or may run past them (:off). The default value is:on.
The weights' extent is 1.232 wide and the mileages' 4.51 high, so with a unit of y a quarter as long as a unit of x the panel is 0.92 times as tall as it is wide:
iex> svg =
...> %{"wt" => [2.32, 2.62, 3.44], "mpg" => [22.8, 21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.coord_fixed(ratio: 0.25)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> [width, height] =
...> ~r{width='([\d.]+)' height='([\d.]+)' style='[^']*fill: #EBEBEB}
...> |> Regex.run(svg, capture: :all_but_first)
...> |> Enum.map(&String.to_float/1)
iex> Float.round(height / width, 2)
0.92
Draws the plot in radial coordinates, replacing any coordinate system the plot had: x is the
angle, running clockwise round a full circle from 12 o'clock, or from start: to end:, and y
the radius, out from the centre, or with theta: :y the other way round, so a stacked bar of
one column becomes a pie.
The scales are expanded as cartesian ones are unless expand: says otherwise, so the marks keep
clear of the circle's edge and centre, and the first and last positions on the angle are a gap
apart at 12 o'clock; unexpanded, they meet there, and where the angle's first and last breaks
meet, the last is labelled with both, the first's label then a slash. thetalim: and rlim:
zoom an axis as coord_cartesian/2's xlim: does, and a limit of a type its scale does not
take is refused when the plot is run.
Each panel is square, its grid a circle at each of the radius's breaks and a spoke at each of
the angle's, on a disc. The angle's axis is drawn round the circle inside the panel and its title
below the panel, above it where its scale's position: is :top or :right; the radius's axis
is drawn to the panel's left, up the radius at 12 o'clock, or to its right where its scale's
position: is :right or :top. Nothing is clipped at the panel's edges unless clip: :on
says so: then what the layers draw is cut off at the disc or sector, and the angle's axis and
the panel's border at its edges, but not a radius axis inside it.
An arc short of a full turn draws a sector on a panel shaped to it, the radius's axis inside it
along the spoke at the arc's start, or at its end where its scale's position: puts it right,
its labels level; on an arc reaching neither 12 nor 6 o'clock the titles change places, the
radius's below the panel and the angle's to its left. r_axis_inside: moves the radius's axis:
inside a full circle along the spoke at 12 o'clock, or at a value of the angle's, or beside a
sector, where an arc reaching neither 12 nor 6 o'clock draws it below the panel. Raises
ArgumentError for r_axis_inside: false on an arc reaching none of 12, 3, 6 and 9 o'clock; a
value of a type the angle's scale does not take is refused when the plot is run.
inner_radius: cuts a hole in the middle, the radius running from its edge, its axis and grid
with it, so a pie becomes a donut. reverse: runs the angle anticlockwise from end: to
start:, the radius in from the edge, or both; with the angle reversed the radius axis inside
the panel is drawn on the other side of its spoke, and on a sector round 3 or 9 o'clock with
the axis inside the titles keep their sides, as ggplot2's do.
rotate_angle: true turns each text's and label's angle by where it falls round the circle, so
at an angle of 0 it reads along the circle there, and a half turn more where it would read
upside down, its hjust: and vjust: then mirrored; a word hjust: or vjust:, which cannot
be mirrored, is refused with ArgumentError when the plot is drawn.
Options
:theta- Which position is the angle round the circle,:xor:y; the other is the radius out from its centre. The default value is:x.:thetalim- The angle's extent to zoom to, ascoord_cartesian/2'sxlim:gives x's: in data units, a discrete axis's as positions,nilfor an end the scale decides, in either order, every row reaching the stats. The default value is{nil, nil}.:rlim- The radius's extent to zoom to, asthetalim:gives the angle's. The default value is{nil, nil}.:expand- Whether each axis's extent is widened by its scale's expansion (true), or is exactly its limits, the scale's orthetalim:andrlim:(false); or a keyword list of:top,:right,:bottomand:left, eachtrueorfalse, a side left out widened: x's low end is:leftand its high end:right, y's low end:bottomand its high end:top, whichever of them is the angle. The default value istrue.:start- Where the angle starts, in radians clockwise from 12 o'clock. The default value is0.0.:end- Where the angle ends, in radians clockwise from 12 o'clock, a full turn paststart:when not given; an end before the start is reached by winding the start back whole turns. An arc short of a full turn draws a sector, the panel shaped to it, the radius axis inside it along the start's spoke.:r_axis_inside- Where the radius axis is drawn:trueinside the panel, along the spokes at the arc's start and end;falsebeside the panel, left of it, or below it on an arc reaching neither 12 nor 6 o'clock; or a value on the angle's axis, in data units asthetalim:takes them, inside the panel along the spoke there, or a pair of them,{first, second}, the first for an axis drawn left of its spoke and the second for one drawn right of it, the radius axis's copy among them; a value past the angle's extent stands at its end. When not given,falseon an arc of 1.999 half turns or more andtrueon any shorter.falseon an arc reaching none of 12, 3, 6 and 9 o'clock is refused, there being no side to draw it on.:inner_radius- The size of a hole in the middle, as a share of the circle's radius, from 0, none, to below 1; the radius's extent runs from the hole's edge to the circle's. The default value is0.0.:reverse- Which positions run from their high end to their low end: the angle (:theta), anticlockwise fromend:tostart:, the radius (:r), from the edge in to the centre or the hole, both (:thetar) or neither (:none). Reversing the angle draws the radius axis inside the panel on the other side of its spoke. The default value is:none.:clip- Whether what the layers draw in each panel is cut off at the disc or sector, and the rest of the panel at its edges (:on), or may run past them (:off). The default value is:off.:rotate_angle(boolean/0) - Whether each text's or label's angle is turned with the circle at its place, read from the line along the angle, and a half turn more where it would read upside down, its justification then mirrored, which takes numbers alone. The default value isfalse.iex> svg = ...> %{"wt" => [2.32, 2.62, 3.44], "mpg" => [22.8, 21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.coord_radial() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> svg =~ "<polygon" true
Unexpanded, the shares 0 and 100 meet at 12 o'clock, and the angle's axis labels the break there with both:
iex> svg =
...> %{"share" => [0, 30, 55, 100], "radius" => [1, 2, 3, 4]}
...> |> Giggly.Plot.new(%{x: :share, y: :radius})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.coord_radial(expand: false)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ ">0/100</text>"
true
Draws the plot in cartesian coordinates whose axes are each put through a transformation of
their own once the stats have run, replacing any coordinate system the plot had: x: :log10
spaces the x axis logarithmically while every stat, a smooth's fit and a histogram's bins among
them, sees the data as it is, where a scale's transform: changes what the stats see. A
straight line in the data bends in the panel, so lines, polygons, axis lines and the sides of
rectangles, bars and tiles are cut into steps that follow the bend.
Each axis is widened in the transformation's space, so the marks keep clear of the panel's
edges, and its breaks are its scale's, labelled in data units. xlim:, ylim:, expand:,
reverse: and clip: are coord_cartesian/2's. An axis the transformation cannot place, one
reaching 0 under :log10 as a histogram's counts do, is refused when the plot is run, as is a
limit of a type the axis's scale does not take.
Options
:x- What the x axis's positions are put through once the stats have run, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. A date, date-time or time one is refused, where ggplot2 fails on one. The default value is:identity.:y- What the y axis's positions are put through, asx:says. The default value is:identity.:xlim- The x axis's extent to zoom to,{low, high}in data units: two numbers, two dates, two date-times or two times of day, as the axis's scale takes them, a discrete axis's as positions, its first value at 1, andnilfor an end the scale decides; in either order. The data is unchanged, every row reaching the stats, and a mark past the extent is cut off at the panel's edge, where a scale's limits leave out the rows outside them. The default value is{nil, nil}.:ylim- The y axis's extent to zoom to, asxlim:gives x's. The default value is{nil, nil}.:expand- Whether each axis's extent is widened by its scale's expansion (true), or is exactly its limits, the scale's orxlim:andylim:, (false); or a keyword list of the panel's sides,:top,:right,:bottomand:left, eachtrueorfalse, a side left out widened. The default value istrue.:reverse- Which axes run from their high end to their low end::x,:y, both (:xy) or neither (:none). The scales and their breaks are as they were, and the axes stay below and left of each panel. The default value is:none.:clip- Whether what is drawn in each panel is cut off at its edges (:on), or may run past them (:off). The default value is:on.
On a logarithmic x axis the points keep their rows, and the weights are labelled where the scale breaks them:
iex> plot =
...> %{"wt" => [1.5, 3.0, 5.4], "mpg" => [30.4, 19.2, 10.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.coord_transform(x: :log10)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[1.5, 3.0, 5.4]
iex> plot.coord.x
:log10
Splits the plot into a grid of panels: a row of panels for each combination of values of the
rows: facets that occurs in the data, and a column of panels for each of the cols: facets',
each side a facet or a list of them, as facet_wrap/3 takes its facets:
facet_grid(plot, rows: :drv, cols: :cyl). Leaving one out gives a single column or a single
row of panels.
Each layer's rows are drawn in the panel of their values. The rows' values and the columns' are
each those the plot's data and every layer's own table make together, and every row is crossed
with every column, so a pair of values no table holds still has a panel, drawn empty. A table
lacking some of the columns is drawn in every panel of the values it has, so one lacking them
all is drawn in every panel. The rows, and the columns, are ordered by their first column's
values, then the next's, as an axis orders its levels, with a missing value (nil) last.
Each column of panels is labelled by strips above the first row, and each row by strips right of
the last column, turned to read downward unless the theme says otherwise (strip_text_y): a
strip for each column split on, the first outermost, labelled with its value unless
labeller: says otherwise. switch: moves the columns' strips below the last row, the first
nearest the panels, or the rows' left of the first column, turned to read upward
(strip_text_y_left), the first outermost, or both.
The panels share each axis's scale, and an axis is drawn only at the grid's outer edges unless
axes: draws it on every panel, its labels there unless axis_labels: leaves them off. Free
scales give each column of panels an x scale of its own and each row a y scale, trained on its
panels' rows alone; unless axes: says otherwise, the axes stay at the edges, each column's
below it and each row's left of it. The panels are all one size unless space: makes each
column as wide as its x axis is long, each row as tall as its y axis is, or both, so a unit of
a free axis is as long in every panel. Under a fixed ratio, coord_fixed/2, space free both
ways keeps the ratio and lets the scales be free; free one way, it sizes that way by the
lengths and the other by the first panel's shape, so the panels lose the ratio. Each axis fits
what the layers draw once their stats have run, unless shrink: false keeps the range of the
data before the stats too.
Options
:rows(term/0) - The facet, or list of facets, whose values give the rows of panels, each asfacetsis given tofacet_wrap/3. The default value is[].:cols(term/0) - The facet, or list of facets, whose values give the columns of panels, each asfacetsis given tofacet_wrap/3. The default value is[].:scales- Whether the panels share each axis's scale (:fixed), or each column of panels has its own x scale (:free_x), each row its own y scale (:free_y), or both (:free). The default value is:fixed.:labeller- How each strip is labelled from its panel's values::value,:both,:context,:wrap, one of them with its options, a function, a map, or a keyword list labelling each side or column apart, as "Labelling the strips" says. The default value is:value.:axes- Which axes every panel draws: those at the panels' outer edges alone (:margins), or every panel's x axes (:all_x), y axes (:all_y) or both (:all). The default value is:margins.:axis_labels- Which of the axesaxes:adds inside the grid keep their labels: all of them (:all), none, the outer edges' alone keeping theirs (:margins), or the x axes' (:all_x) or the y axes' (:all_y) alone; free scales or not. The default value is:all.:margins- Whether to add margins, panels holding all the data of a facet's values, labelled(all):false, none;true, one for every facet; or the facets to add them for, by name. A margin for a facet is one for every facet after it on its side too, and the rows' and columns' margins cross, the corner panel holding all the data. The default value isfalse.:as_table(boolean/0) - Whether the rows run as a table's, the first value at the top (true), or as a plot's axis, the first at the bottom (false), a missing value last either way. The default value istrue.:space- Whether the panels are all one size (:fixed), or each column of panels is as wide as its x axis is long (:free_x), each row as tall as its y axis is (:free_y), or both (:free). The default value is:fixed.:shrink(boolean/0) - Whether the x and y scales fit only what the stats compute (true), or keep the range of the data before the stats too (false), so a summary's axis spans every value summarised;falserefuses a binned x or y scale when the plot is run. The default value istrue.:switch- Which strips go to the other side: the columns' below the panels instead of above (:x), the rows' left of them instead of right (:y), or both (:both). Beside an axis they sit between it and the panels unless the theme'sstrip_placementputs them beyond it.:drop(boolean/0) - Whether values no row uses are left out (true), or every level of a factor is given panels, empty where no row holds it (false). A table holding only some of the facets' columns crosses its values undertrue, every level of a factor among them, and adds its rows as they are underfalse, as ggplot2 does. The default value istrue.
Raises ArgumentError when neither rows: nor cols: gives a facet, a facet is named twice,
in one of them or in both, a facet is one facet_wrap/3 refuses, margins: names a facet the
grid has not, or the labeller's columns: names a facet of a side its rows: or cols:
labels, and NimbleOptions.ValidationError for an
option it does not take or a labeller it cannot use. When the plot is run, since a layer added
later may bring a column, it raises ArgumentError unless the plot's data or some layer's own
table holds every column the facets of rows: read, and likewise of cols:, when a table
cannot compute a facet, when no table has a row to make a panel from, when space: sizes
the panels under coord_radial/2, whose panels have no x or y length, and when shrink: false
meets a binned x or y scale, whose bins are fixed before the stats.
iex> plot =
...> %{
...> "wt" => [2.32, 2.62, 3.44, 2.2],
...> "mpg" => [22.8, 21.0, 18.7, 32.4],
...> "am" => [1, 1, 0, 1],
...> "cyl" => [4, 6, 8, 4]
...> }
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.facet_grid(rows: :am, cols: :cyl)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:panel)
[4, 5, 3, 4]Labelling the strips
Each strip is labelled from its panel's values by labeller:, the value alone unless it says
otherwise:
:value, the value alone, as a table writes it:4for a whole float,TRUE;:both, the facet's name and the value,cyl: 4;:context, the value alone where a side's strips are for one facet, and both where they are for several;:wrap, the value alone broken between its words into lines shorter than 25 columns, a word wider than that on a line of its own, asScales.Labels.wrap/2breaks it (a Chinese, Japanese or Korean character or an emoji takes two columns): the whitespace between words becomes one space, or two after a sentence's end that two or more followed, and a line holding only whitespace starts a paragraph, an empty line before it;- one of these with its options, such as
{:both, sep: "=", multi_line: false}:sep:goes between the name and the value (": "),width:sets how many columns:wrapkeeps a line under ({:wrap, width: 10}), andmulti_line: falseputs a panel's labels in one strip, joined by", ", in place of a strip for each facet (4, f, or under:both cyl, drv: 4, f, and under:wrapthe labels joined and then broken); - a function, handed each label as
:valuewrites it and returning the label to show; - a map of labels to the labels to show,
%{"0" => "Zero", "1" => "One"}, a label it lacks shown asNA.
A function or a map may also give a label another library lays out (Giggly.Label), shown in
its strip as it is, sized and placed as a title holding one is. Such a label is refused
wherever a labeller writes text with it: :both, :context over several facets and :wrap,
as the default writing a function's labels or a facet's own, and multi_line: false, which
joins them.
A missing value is shown as NA, and is never handed to a function or looked up. A label
holding a line break, whichever labeller writes it, is drawn in a strip of several lines,
spaced by the strip text's lineheight:.
A keyword list labels the sides, or the facets, apart:
rows:andcols:, the labeller of every strip of the rows or of the columns of panels; a wrap's strips are one side, labelled by either;columns:, a keyword list or a map of a labeller for each facet it names, by the facet's name, a column's own. A name the facet does not split on is passed over, so one list can label several plots. A label a facet's own labeller leaves missing, as a map does one it lacks, is the default's;default:, the labeller of every other facet (:value), which also writes the labels a function or a map gives: under[columns: [vore: &String.upcase/1], default: :both]the strip of"carni"showsvore: CARNI;multi_line:, whether each facet's label is a strip of its own (true), or one strip joins them,cyl: 4, drv: f.
In the list a labeller takes its options but not multi_line:, which is the list's. A side
whose strips have a labeller of their own cannot also have its facets labelled apart.
@spec facet_wrap(t(), facet_argument() | [facet_argument()], keyword()) :: t()
Splits the plot into panels, one for each combination of values of the facets that occurs in
the data, laid out in rows. facets is a facet or a list of them: facet_wrap(plot, :class) or
facet_wrap(plot, [:cyl, :drv]). A facet is whatever a mapping maps an aesthetic to, a column,
an expression, a factor, a reordering or a cut, computed in each row of each table: {:reorder, [:class, :displ]} orders the panels by each class's mean displ, and {:cut_width, [:displ], width: 1} makes a panel of each litre of it. It is named by its text, as an
axis is titled, so a column by its own name and {&Kernel.*/2, [:cyl, 2]} as cyl * 2, or by
the name {name, value} gives it, an atom or a string: facet_wrap(plot, [:drv, cylinders: :cyl]). A facet's name is the one its strips' labeller writes and its columns: names it by.
Each layer's rows are drawn in the panel of their values. The panels are those the plot's data
and every layer's own table make together; a table lacking a column a facet reads lacks that
facet, and is drawn in every panel of the values it has, so one lacking them all is drawn in
every panel. The panels are
ordered by the first column's values, then the next's, as an axis orders its levels, with a
missing value (nil) last, and fill the rows left to right from the top unless dir: starts
them in another corner or fills the columns first. With neither nrow: nor ncol:,
up to three panels make one row, up to six two rows, up to twelve three, and more a square or
nearly one; given one of the two, the other is as many as the panels need.
The panels share each axis's scale, and an axis is drawn only at the panels' outer edges unless
axes: draws it on every panel, its labels there unless axis_labels: leaves them off. Free
scales give each panel a scale of its own, trained on its rows alone, and its own labelled
axis. The panels are all one size unless space: lays them out in one row, each as wide as its
x axis is long, or in one column, each as tall as its y axis is, so a unit of a free axis is as
long in every panel. Under a fixed ratio, coord_fixed/2, the scales cannot be free, and space:
sizes its way by the lengths and the other by the first panel's shape, so the panels lose the
ratio. Each axis fits what the layers draw once their stats have run, a summary's means alone,
unless shrink: false keeps the range of the data before the stats too.
Each panel has a strip above it for each facet, in the order given, labelled with its value
unless labeller: says otherwise, or below it, left of it or right of it where
strip_position: says, the first facet outermost but below the panel, where it is nearest.
Options
:nrow(pos_integer/0) - How many rows to lay the panels out in.:ncol(pos_integer/0) - How many columns to lay the panels out in.:scales- Whether the panels share each axis's scale (:fixed), or each panel has its own x scale (:free_x), y scale (:free_y) or both (:free), and draws its own axis for each. The default value is:fixed.:labeller- How each strip is labelled from its panel's values::value,:both,:context,:wrap, one of them with its options, a function, a map, or a keyword list labelling each side or column apart, as "Labelling the strips" says. The default value is:value.:axes- Which axes every panel draws: those at the panels' outer edges alone (:margins), or every panel's x axes (:all_x), y axes (:all_y) or both (:all). The default value is:margins.:axis_labels- Which of the axesaxes:adds inside the grid keep their labels: all of them (:all), none, the outer edges' alone keeping theirs (:margins), or the x axes' (:all_x) or the y axes' (:all_y) alone; an axis whose scales are free keeps its labels on every panel. The default value is:all.:dir- Where the panels start and which way they fill::halong each row from the top left,:vdown each column from the top left, or a start corner,torbwithlorr, its first letter the way filled first::rtfrom the top right, right to left along each row;:blfrom the bottom left, up each column.:his:ltand:vis:tl. The default value is:h.:space- Whether the panels are all one size (:fixed), or laid out in one row, each as wide as its x axis is long (:free_x), or in one column, each as tall as its y axis is (:free_y);:free_xtakes noncol:and nonrow:but 1, and:free_ynonrow:and noncol:but 1. The default value is:fixed.:shrink(boolean/0) - Whether the x and y scales fit only what the stats compute (true), or keep the range of the data before the stats too (false), so a summary's axis spans every value summarised;falserefuses a binned x or y scale when the plot is run. The default value istrue.:strip_position- Which side of each panel its strips go on::top,:bottom,:leftor:right. Beside an axis they sit between it and the panel unless the theme'sstrip_placementputs them beyond it. The default value is:top.:drop(boolean/0) - Whether values no row uses are left out (true), or every level of a factor is given panels, empty where no row holds it (false). A table holding only some of the facets' columns crosses its values undertrue, every level of a factor among them, and adds its rows as they are underfalse, as ggplot2 does. The default value istrue.
Raises ArgumentError for a facet named twice or none at all, a value a mapping cannot take, an
after_stat, one reading no column, which makes one panel, an unnamed expression with a closure
in it, which has no text to name it by, or a labeller whose columns: names a facet when
rows: or cols: labels every strip, and NimbleOptions.ValidationError for an option it does
not take, a count that is not a positive whole number, or a labeller it cannot use, rows: and
cols: together among them, and ArgumentError for space: :free_x beside ncol: or an
nrow: but 1, or space: :free_y beside nrow: or an ncol: but 1, since each lays the
panels out in one row or column. When the plot is run, since a layer added later may bring a
column, it raises ArgumentError unless the plot's data or some layer's own table holds every
column the facets read, when a table cannot compute a facet, when nrow: and ncol: together
hold fewer panels than there are, when no table has a row to make a panel from, when
space: sizes the panels under coord_radial/2, whose panels have no x or y length, and when
shrink: false meets a binned x or y scale, whose bins are fixed before the stats.
iex> plot =
...> %{"wt" => [2.32, 2.62, 3.44, 2.2], "mpg" => [22.8, 21.0, 18.7, 32.4], "cyl" => [4, 6, 8, 4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.facet_wrap(:cyl)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:panel)
[1, 2, 3, 1]Under labeller: :both each strip shows the column's name beside its value:
iex> svg =
...> %{"wt" => [2.32, 2.62], "mpg" => [22.8, 21.0], "cyl" => [4, 6]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.facet_wrap(:cyl, labeller: :both)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> Enum.map(["cyl: 4", "cyl: 6"], fn label -> svg =~ ">" <> label <> "</text>" end)
[true, true]Labelling the strips
Each strip is labelled from its panel's values by labeller:, the value alone unless it says
otherwise:
:value, the value alone, as a table writes it:4for a whole float,TRUE;:both, the facet's name and the value,cyl: 4;:context, the value alone where a side's strips are for one facet, and both where they are for several;:wrap, the value alone broken between its words into lines shorter than 25 columns, a word wider than that on a line of its own, asScales.Labels.wrap/2breaks it (a Chinese, Japanese or Korean character or an emoji takes two columns): the whitespace between words becomes one space, or two after a sentence's end that two or more followed, and a line holding only whitespace starts a paragraph, an empty line before it;- one of these with its options, such as
{:both, sep: "=", multi_line: false}:sep:goes between the name and the value (": "),width:sets how many columns:wrapkeeps a line under ({:wrap, width: 10}), andmulti_line: falseputs a panel's labels in one strip, joined by", ", in place of a strip for each facet (4, f, or under:both cyl, drv: 4, f, and under:wrapthe labels joined and then broken); - a function, handed each label as
:valuewrites it and returning the label to show; - a map of labels to the labels to show,
%{"0" => "Zero", "1" => "One"}, a label it lacks shown asNA.
A function or a map may also give a label another library lays out (Giggly.Label), shown in
its strip as it is, sized and placed as a title holding one is. Such a label is refused
wherever a labeller writes text with it: :both, :context over several facets and :wrap,
as the default writing a function's labels or a facet's own, and multi_line: false, which
joins them.
A missing value is shown as NA, and is never handed to a function or looked up. A label
holding a line break, whichever labeller writes it, is drawn in a strip of several lines,
spaced by the strip text's lineheight:.
A keyword list labels the sides, or the facets, apart:
rows:andcols:, the labeller of every strip of the rows or of the columns of panels; a wrap's strips are one side, labelled by either;columns:, a keyword list or a map of a labeller for each facet it names, by the facet's name, a column's own. A name the facet does not split on is passed over, so one list can label several plots. A label a facet's own labeller leaves missing, as a map does one it lacks, is the default's;default:, the labeller of every other facet (:value), which also writes the labels a function or a map gives: under[columns: [vore: &String.upcase/1], default: :both]the strip of"carni"showsvore: CARNI;multi_line:, whether each facet's label is a strip of its own (true), or one strip joins them,cyl: 4, drv: f.
In the list a labeller takes its options but not multi_line:, which is the list's. A side
whose strips have a labeller of their own cannot also have its facets labelled apart.
@spec geom_abline(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of diagonal reference lines: a line across the whole panel for each intercept
and slope, y = intercept + slope * x, for a line of equality, a fitted line worked out
elsewhere, or a rule of thumb drawn over the data.
The lines are given in one of two ways. intercept: and slope: give them as values, a line
for each, drawn in every panel and in no legend; given neither, nor a mapping, the layer draws
the line y = x. Or the layer maps both :intercept and :slope from a table, its own
data: or the plot's, so the lines can differ from panel to panel under a facet and map a
colour, alpha, width or line type into a legend. Either way the layer takes nothing from the
plot's mapping, and titles no axis.
Diagonal lines use :intercept, :slope, :group, :alpha, :color, :linetype and
:linewidth, and need :intercept and :slope, numbers in the axes' positions, the units
their scales transform into, so under scale_y_log10/2 an intercept of 1 crosses at 10; on a
discrete axis the levels sit at 1, 2, 3 and on. Neither widens an axis or goes through a
scale. A line repeated in a panel is drawn once. Beside intercept: or slope:, each look
option takes one value or a list, one per line, every list as long as the others. A line
missing its intercept or slope draws nothing, and so do an infinite one, a colour of :none
and the line type :blank. A line that misses the panel is still drawn, beyond its edges:
hidden where the panel is clipped, but under coord_cartesian(clip: :off) and
coord_radial/2, which clips only with clip: :on, it may show outside the panel, a spiral
under radial coordinates. A flat line exactly on the edge of such a panel draws nothing.
Raises ArgumentError for intercept: or slope: beside a mapping or data:, for data:
without a mapping, for a list of looks without intercept: or slope:, for lists of
different lengths, and when the plot is run for a mapped intercept or slope that is not a
number.
Options
:data(term/0) - A table for the layer's mapping to draw from instead of the plot's data, anything implementingTable.Reader; refused beside the options giving lines as values, which draw lines of their own. Under a facet, a table lacking a faceting column is drawn in every panel.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added. Taken only beside a mapping.:intercept- Where each line crosses x = 0, in the y axis's positions, the units its scale transforms into: a number, or a list of them, a line for each, drawn in every panel; 0 when onlyslope:is given. Given, the layer takes no mapping and nodata:.:slope- How far each line rises along y for each unit along x, in the axes' positions: a number, or a list of them, a line for each; 1 when onlyintercept:is given. Given, the layer takes no mapping and nodata:.:alpha- How opaque each line is, from 0, invisible, to 1, opaque.:color- The colour of each line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide each line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of each line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.iex> frame = ...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.geom_abline(intercept: 37, slope: [-5, -4], colour: "red") ...> |> Giggly.layer_data(1) iex> {Giggly.DataFrame.pull(frame, :intercept), Giggly.DataFrame.pull(frame, :slope)} {[37.0, 37.0], [-5.0, -4.0]}
A line for each panel, mapped from a table of its own:
iex> frame =
...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7], "cyl" => [4, 8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.geom_abline(%{intercept: :intercept, slope: :slope},
...> data: %{"cyl" => [4, 8], "intercept" => [40.0, 20.0], "slope" => [-5.0, -1.0]}
...> )
...> |> Giggly.Plot.facet_wrap(:cyl)
...> |> Giggly.layer_data(1)
iex> {Giggly.DataFrame.pull(frame, :slope), Giggly.DataFrame.pull(frame, :panel)}
{[-5.0, -1.0], [1, 2]}
@spec geom_area(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of areas: the band from 0 to each group's y along its x, for how much a series
holds over time, or from 0 to its x up its y with orientation: :y.
Areas use :x, :y, :group, :alpha, :fill, :color, :linetype and :linewidth, and
need :x and :y. Each group is an area of its own, its rows in order along it, and areas at
one x are piled on one another, the first group on top, unless position: :identity draws
each where it is. So that groups whose rows sit at different places pile into one another, each
group with more than one row is first worked out at every x the panel's groups have, and
wherever a group crosses 0, along a straight line between its own rows, and at its ends drops to
0 a hair beyond them. A row missing x or y is left out. An area is filled, at its alpha, and
its upper edge outlined only where a colour is mapped or set, taking no alpha but its colour's
own; its look cannot change along it, as a ribbon's cannot (geom_ribbon/3).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:align.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:stack.:orientation- The axis each area runs along::x, from 0 up to itsy, or:y, from 0 across to itsx, for areas that run up the panel. The default value is:x.:outline_type- Which of each band's edges its outline draws: the upper and the lower, each a line (:both), the upper alone (:upper), the lower alone (:lower), or the band's whole border (:full). The default value is:upper.:alpha- How opaque every band's fill is, from 0, invisible, to 1, opaque; its outline keeps its colour's own alpha.:color- The colour of every band's outline, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no outline when not given.:fill- The colour every band is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every band's outline is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every band's outline::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"t" => [1, 2, 1, 2], "g" => ["a", "a", "b", "b"], "v" => [1.0, 1.0, 2.0, 2.0]} ...> |> Giggly.Plot.new(%{x: :t, y: :v, fill: :g}) ...> |> Giggly.Plot.geom_area() ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :ymax) [0.0, 3.0, 3.0, 3.0, 3.0, 0.0, 0.0, 2.0, 2.0, 2.0, 2.0, 0.0]
@spec geom_bar(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of bars counting the rows at each x. Each bar runs from 0 to the number of rows at
its x, or, where :weight is mapped, to the sum of their weights, and the y axis is titled
count. A row missing its x is not counted. The bars are drawn as geom_col/3 draws them.
Counting uses :x or :y, :weight and :group, and needs exactly one of :x and :y: it
counts along the one mapped, so mapping :y alone draws horizontal bars. A :weight column must
hold numbers. The bars also take :alpha, :fill, :color, :linetype and :linewidth; one
reaches a bar only where it is the same in every row the bar counts, so a discrete one groups the
rows and gives each group its own bar. Each bar is 0.9 times the closest spacing of the x
positions wide, counting from zero, 0.9 on a discrete axis, unless width: says otherwise; counting gives every bar its
width, so :width is not mapped. just: places each bar against its x.
Counting computes count and prop, the count's share of its group's total, which a mapping
reads with an after_stat (Giggly.Mapping): %{x: :class, y: {:after_stat, [:prop]}, group: 1}
draws each class's share of all the rows.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:count.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:stack.:orientation- The axis the layer runs along,:xor:y, which must be the one of:xand:ymapped; it runs along that one when this is not given.:width- How wide every bar is, in the units of the axis it stands on, any number; it replaces the width the bars would take otherwise, and a mapped:width.:just- Where each bar sits against its position, a number from 0 to 1: 0 puts its lower edge there, 1 its upper edge, and 0.5 centres it. The default value is0.5.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every bar's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every bar is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 35% toward its paper,#595959, or#000000A6undertheme_void/2, whose paper is clear.:linewidth- How wide every bar's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every bar's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"class" => ["suv", "compact", "suv"]} ...> |> Giggly.Plot.new(%{x: :class}) ...> |> Giggly.Plot.geom_bar() iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :count) [1.0, 2.0]
@spec geom_bin_2d(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of rectangles counting the rows in each, binning in two dimensions: the plane cut
into rectangles along x and y, and for each group a tile wherever a row falls, filled by
how many rows fall in it, or, where :weight is mapped, by the sum of their weights. A heatmap
of two continuous variables, it shows where many rows overlap, as points drawn over one another
cannot.
Each axis is cut into 30 bins across each panel's axis unless bins:, binwidth: or
breaks: says otherwise, the bins meeting at 0 unless boundary: or center: places them;
every group in a panel is cut alike. A row falls in the rectangle it is inside, one on an edge
in the bin closed: gives it. A row missing its x or y, or at an infinite one, is not
counted; a missing weight makes its rectangle's count missing.
Binning in rectangles uses :x, :y, :weight and :group, and needs :x and :y. A
:weight column must hold numbers. The tiles also take :alpha, :fill, :color,
:linetype and :linewidth; one reaches a tile only where it is the same in every row of its
group, so a discrete one groups the rows. Each is filled by its count through the fill scale,
which titles the legend count, unless a fill is mapped or set, and drawn without a border
unless a colour is mapped or set.
Binning in rectangles computes, for each rectangle, count; ncount, the count over the
group's largest; density, the count over the group's total; and ndensity, the density over
the group's largest. A mapping reads them with an after_stat (Giggly.Mapping): %{x: :x, y: :y, fill: {:after_stat, [:density]}} fills each tile by its share of the rows.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:bin_2d.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins- How many bins span each axis, when neitherbinwidth:norbreaks:is given: a whole number above 0 for both, or{x_bins, y_bins}. The default value is30.:binwidth- How wide and how high each rectangle is, in the axes' transformed units, which takes the place ofbins:: a number above 0 for both, or{width, height}.:breaks- Where the bins meet, two or more distinct numbers in the data's units, put through each axis's transformation, for both axes or as{x_breaks, y_breaks}, which takes the place ofbins:,binwidth:,center:andboundary:; a row outside them is not counted.:center- Where one bin's middle falls along each axis, which places them all: a number for both, or{x, y}; not withboundary:.:boundary- Where two bins meet along each axis, which places them all: a number for both, or{x, y}; not withcenter:. Without either, bins meet at 0.:closed- Which end of a bin a value on its edge belongs to, along each axis: the right end (:right) or the left (:left) for both, or{x_closed, y_closed}; the outermost bins hold their outer ends too. The default value is:right.:drop(boolean/0) - Whether to leave out each rectangle no row falls in;falsekeeps one at every x bin and y bin some row of its group falls in. The default value istrue.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every tile's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every tile is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every tile's border is, in millimetres; 0.4 times the theme'sbase_line_sizewhen not given, 0.2 at its default sizes.:linetype- The line type of every tile's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 1.2, 2.5, 3.0, 4.0], "y" => [1.0, 1.1, 2.0, 3.5, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_bin_2d(binwidth: 1) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :count) [2.0, 1.0, 1.0, 1.0]
@spec geom_blank(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer that draws nothing: its rows widen the axes, and the scale of any other aesthetic it maps, as a layer drawing them would, so a table of the values every plot of a set should reach gives them the same scales. A plot with no layers is drawn as though it had this one, taking the plot's mapping, so its axes span the mapped columns and are titled by them.
Its mapping may name any aesthetic, needs none, and draws in no legend; another layer drawing an aesthetic it maps shows the values both hold. It takes no option setting how its marks look, having none.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.geom_blank(data: %{"wt" => [0], "mpg" => [0]}) iex> Giggly.panel_scales(plot).x.range {0, 2.875}
A plot with no layers trains its axes on the plot's mapping:
iex> plot = Giggly.Plot.new(%{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}, %{x: :wt, y: :mpg})
iex> Giggly.panel_scales(plot).y.range
{21.0, 22.8}
@spec geom_boxplot(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of box plots, a box for each group summarising its y: from its lower quartile to
its upper, a line across it at its median, and whiskers out to the least and greatest y within
coef: heights of the box beyond it, every value further out drawn as a point, an outlier. The
quartiles are R's default (type 7). Each box stands at the middle of its group's x values,
0.75 times the closest spacing of the x positions wide, counting from zero, 0.75 on a
discrete axis, or 0.9 of the
range of its group's x values where they are several, or as wide as its group's first mapped
:width, a number, or as width: says. A row missing its x or y, or at an infinite one, is
left out.
Boxes stand along the discrete one of x and y, so mapping a discrete y beside a numeric x
draws horizontal boxes summarising x; mapping one of them alone summarises it, a single box at
0; where both are continuous, they stand along the axis on which every group holds one value,
or else along x, each group a box, so a numeric x takes a :group to draw more than one.
orientation: says which. Boxes sharing a position are set side by side, as position: says.
Raises ArgumentError for varwidth: true beside a position other than :dodge2, or beside
{:dodge2, preserve: :total}, since each box keeps its own width.
Box plots use :x, :y, :group, :width, :alpha, :color, :fill, :linetype and
:linewidth, and :shape and :size, which the outliers take, and need :x or :y. A look
reaches a box only where it is the same in every row of its group, so a discrete one groups the
rows and gives each group its own box. A box plot is not weighted, so a :weight the plot's
mapping gives is refused. The whiskers, staples, median and box's border each take a look of
their own (whisker_color: and the like), and the outliers theirs (outlier_color: and the
like), else the box's.
Given another stat in stat:, a layer maps each box's parts itself: :ymin, :lower,
:middle, :upper and :ymax, or for horizontal boxes :xmin, :xlower, :xmiddle,
:xupper and :xmax, each needed, and draws them as given, with no outliers and, under
varwidth: true, each box its plain width. The boxes stand as orientation: says, else across
where y alone is discrete and up otherwise, and parts the other way's are refused: a layer
laying boxes across on a continuous y gives orientation: :y. Each group is drawn as one box,
so rows on a continuous axis, one group unless :group is mapped, are refused as they are drawn.
notch: true is refused beside another stat, since only the box plot's own computes notches.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:boxplot.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the boxes are moved once the stat has run: set side by side, each its share of their widths, with a gap between them (:dodge2), set side by side within the width one box takes or the width given (:dodge), left at their positions (:identity), or nudged (:nudge), each alone or with its options, as Positions says. Withvarwidth: true, every box keeps its own width, which only:dodge2lays side by side, and so it is the only position taken, itspreserve: :single. The default value is:dodge2.:coef- How far the whiskers may reach past the box, in heights of the box; a value further out is an outlier. The default value is1.5.:width- How wide a box is, in the units of the axis it stands on, any number; it replaces a mapped:width, and gives way to 0.9 of the range of a group spanning several positions. 0.75 times the closest spacing of the positions, counting from zero, when not given.:orientation- The axis the boxes stand along,:xor:y, summarising the other. Where one of:xand:yis mapped, the boxes summarise it, so this must name the other; where both are, it chooses, and when not given the boxes stand along the discrete one, or else along the axis on which every group holds one value, or else along x.:outliers(boolean/0) - Whether to keep the outliers, drawing them and fitting the axes to them;falseleaves them out, the axes fitting the whiskers.outlier_shape: :nonehides them and keeps the axes. The default value istrue.:outlier_color- The outliers' colour, writtenoutlier_colour:oroutlier_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's when not given.:outlier_fill- The colour outliers of a shape with a fill of their own are filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's fill when not given.:outlier_shape- The shape the outliers are drawn in, by name or number, asgeom_point/3takes one, or:nonefor none; the box's:shapewhen not given.:outlier_size- How big the outliers are, in millimetres; the box's:size, the theme's points' size unless the layer sets one, when not given.:outlier_stroke- How heavy the outliers' outlines are, in millimetres, or:nonefor none. The default value is0.5.:outlier_alpha- How opaque the outliers are, from 0 to 1; the box's alpha when not given.:whisker_color- The colour of the whiskers, writtenwhisker_colour:orwhisker_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's colour when not given.:whisker_linetype- The line type of the whiskers::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the box's when not given.:whisker_linewidth- How wide the whiskers is drawn, in millimetres; the box's line width when not given.:staple_color- The colour of the staples, writtenstaple_colour:orstaple_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's colour when not given.:staple_linetype- The line type of the staples::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the box's when not given.:staple_linewidth- How wide the staples is drawn, in millimetres; the box's line width when not given.:median_color- The colour of the median, writtenmedian_colour:ormedian_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's colour when not given.:median_linetype- The line type of the median::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the box's when not given.:median_linewidth- How wide the median is drawn, in millimetres; the box's line width when not given, doubled.:box_color- The colour of the box's border, writtenbox_colour:orbox_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the box's colour when not given.:box_linetype- The line type of the box's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the box's when not given.:box_linewidth- How wide the box's border is drawn, in millimetres; the box's line width when not given.:notch(boolean/0) - Whether to notch each box at its median, the notches reaching 1.58 heights of the box over the square root of its rows either side, so boxes whose notches do not overlap have medians that differ. The default value isfalse.:notchwidth- How wide a notched box is at its median, a share of its width. The default value is0.5.:staplewidth- How wide the staples across the whiskers' ends are, a share of the box's width; 0 draws none. The default value is0.0.:varwidth(boolean/0) - Whether to draw each box as wide as the square root of its rows makes it beside the widest. The default value isfalse.:alpha- How opaque every box's fill and outliers are, from 0 to 1; its lines take none.:color- The colour of every box's lines and outliers, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2.:fill- The colour every box is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's paper when not given, white, or clear undertheme_void/2.:linewidth- How wide every box's lines are, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every box's lines::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:shape- The shape every box's outliers are drawn in, asoutlier_shape:takes one, which wins over it.:size- How big every box's outliers are, in millimetres, asoutlier_size:takes it, which wins over it.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"g" => ["a", "a", "a", "a", "a"], "y" => [1.0, 2.0, 3.0, 4.0, 20.0]} ...> |> Giggly.Plot.new(%{x: :g, y: :y}) ...> |> Giggly.Plot.geom_boxplot() iex> frame = Giggly.layer_data(plot) iex> {Giggly.DataFrame.pull(frame, :middle), Giggly.DataFrame.pull(frame, :outliers)} {[3.0], [[20.0]]}
Boxes computed beforehand, drawn as given:
iex> plot =
...> %{"g" => ["a"], "lo" => [1], "q1" => [2], "q2" => [3], "q3" => [4], "hi" => [5]}
...> |> Giggly.Plot.new(%{x: :g})
...> |> Giggly.Plot.geom_boxplot(
...> %{ymin: :lo, lower: :q1, middle: :q2, upper: :q3, ymax: :hi},
...> stat: :identity
...> )
iex> frame = Giggly.layer_data(plot)
iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)}
{[0.55], [1.45]}
@spec geom_col(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of bars, one per row, each from 0 to its y and centred on its x unless just:
says otherwise, for bars whose heights are in the data. Bars at the same x are stacked, those
below zero downward, the highest group at the bottom; with position: :dodge they are set side
by side within one bar's width, an x with one group keeping its whole width; with position: :dodge2, alone or with its options, bars whose spans overlap are set side by side, each its
share of their widths, with a gap between them.
Each bar is 0.9 times the closest spacing of the x positions wide: 0.9 on a discrete axis
whose neighbouring levels the layer holds, and 1.8 where it skips one, and on a continuous one
0.9 times the closest gap, a column of integers spaced as any numbers are; or as
wide as its mapped :width, a number, or as width: makes every bar, which wins over a mapped
one. just: places each bar against its x, its lower edge there at 0 and its upper at 1. Bars
of different widths at one x are dodged together only by :dodge2. The y axis reaches 0.
Bars use :x, :y, :group, :alpha, :fill, :color, :linetype, :linewidth and
:width, and need :x and :y. :fill fills a bar and takes its alpha; :color borders it,
and bars have no border unless it is mapped or set; :linewidth and :linetype say how wide
the border is and how it is dashed. With a discrete y and a continuous x, the bars are
horizontal.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:stack.:width- How wide every bar is, in the units of the axis it stands on, any number; it replaces the width the bars would take otherwise, and a mapped:width.:just- Where each bar sits against its position, a number from 0 to 1: 0 puts its lower edge there, 1 its upper edge, and 0.5 centres it. The default value is0.5.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every bar's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every bar is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 35% toward its paper,#595959, or#000000A6undertheme_void/2, whose paper is clear.:linewidth- How wide every bar's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every bar's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"trt" => ["a", "b", "c"], "outcome" => [2.3, 1.9, 3.2]} ...> |> Giggly.Plot.new(%{x: :trt, y: :outcome}) ...> |> Giggly.Plot.geom_col() iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :ymin) [0.0, 0.0, 0.0] iex> Giggly.DataFrame.pull(frame, :ymax) [2.3, 1.9, 3.2]
Dodged, the two groups at a share its width, and b's one group keeps all of it:
iex> plot =
...> %{"x" => ["a", "a", "b"], "y" => [1.0, 2.0, 3.0], "g" => ["p", "q", "p"]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, group: :g})
...> |> Giggly.Plot.geom_col(position: :dodge)
iex> frame = Giggly.layer_data(plot)
iex> Giggly.DataFrame.pull(frame, :xmin)
[0.55, 1.0, 1.55]
@spec geom_contour(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of contour lines: for each group, the lines along which a surface, :z over a
grid of :x and :y, stands at each of a set of levels, as the lines on a map join places at
the same height. Every row is a corner of the grid, the grid each group's distinct x and y,
a place no row stands at missing, and a line runs between the grid's points, read linearly
along each side of each cell, at each level it crosses. Rows sharing a place are one, the last
kept; a row missing its x, y or z, or at an infinite one, is left out, and a line around a
missing place stays open. A grid laid at an angle is contoured square and turned back.
The levels are R's pretty() of the range of z over the whole layer, about ten, unless
breaks:, bins: or binwidth: says otherwise, so faceted panels share their levels.
Contour lines use :x, :y, :z, :weight and :group, and need :x, :y and :z; a :z
column must hold numbers. The lines also take :alpha, :color, :linetype and :linewidth,
drawn as geom_path/3 draws a line; one reaches a line only where it is the same in every row
of its group. A line is drawn in the theme's accent, #3366FF by default, unless a colour is
mapped or set.
Contour lines compute, for each point, level, the level its line is drawn at; nlevel, the
level over the group's highest; and piece, its line's number in its group. A mapping reads
them with an after_stat (Giggly.Mapping): %{color: {:after_stat, [:level]}} colours each
line by its level.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:contour.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins(pos_integer/0) - How many levels the lines are drawn at, evenly spaced over the range ofz, which takes the place ofbinwidth:.:binwidth- How far apart the levels are, a number above 0 in the units ofz; a tenth of z's range when a breaks function is given alone.:breaks- The levels the lines are drawn at: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of z's range,{low, high}, and a bin width, returning the levels; R'spretty()of z's range, about ten, when none of them is given.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 1.0, 2.0], "y" => [1.0, 1.0, 2.0, 2.0], "z" => [0.0, 1.0, 1.0, 2.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z}) ...> |> Giggly.Plot.geom_contour(breaks: [1.5]) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)} {[2.0, 1.5], [1.5, 2.0]}
@spec geom_contour_filled(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of contour bands: for each group, the regions where a surface, :z over a grid
of :x and :y, lies between each pair of consecutive levels, filled, as a map's bands of
height are. Each band holds the places at or past its low level and short of its high one; its
rings run round its edges, a band with holes having a ring round each, and are drawn as
geom_polygon/3 draws a shape of several rings. The grid, the rows it is read from and the
levels are geom_contour/3's: R's pretty() of the range of z over the whole layer unless
breaks:, bins: or binwidth: says otherwise, so faceted panels share their bands.
Contour bands use :x, :y, :z, :weight and :group, and need :x, :y and :z; a
:z column must hold numbers. The bands also take :alpha, :color, :fill, :linetype and
:linewidth, as geom_polygon/3 does; one reaches a band only where it is the same in every
row of its group.
Contour bands compute, for each point, level, its band, an ordered factor labelled
"(low, high]", each side written in the fewest significant digits, from 3, that write the
levels apart; level_low and level_high, the band's levels, and level_mid, their mean; and
nlevel, level_high over the group's highest. Each band is filled by its level unless a
fill is mapped or set, the ordered factor taking a colour from the viridis scale.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:contour_filled.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins(pos_integer/0) - How many breaks the bands lie between, evenly spaced over the range ofz, which takes the place ofbinwidth:.:binwidth- How far apart the breaks are, a number above 0 in the units ofz; a tenth of z's range when a breaks function is given alone.:breaks- The breaks the bands lie between, each band from one to the next: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of z's range,{low, high}, and a bin width, returning the breaks; R'spretty()of z's range, about ten, when none of them is given.:alpha- How opaque every shape's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every shape's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every shape is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, each band is filled by its level, through the fill scale.:linewidth- How wide every shape's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every shape's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:rule- How a shape of several rings, each asubgroup, is filled::evenoddleaves out what an even number of its rings surround, so a ring inside another is a hole;:windingfills whatever its rings wind round. The default value is:evenodd.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 1.0, 2.0], "y" => [1.0, 1.0, 2.0, 2.0], "z" => [0.0, 1.0, 1.0, 2.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z}) ...> |> Giggly.Plot.geom_contour_filled(breaks: [0, 1, 2]) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :level) |> Enum.uniq() ["(0, 1]", "(1, 2]"] iex> Giggly.DataFrame.pull(frame, :level_mid) |> Enum.uniq() [0.5, 1.5]
@spec geom_count(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of points counting the rows at each place: one point for each combination of x,
y and the layer's other aesthetics that its rows hold, sized by how many rows hold it, or,
where :weight is mapped, by the sum of their weights, and the size legend titled n. The
points are drawn as geom_point/3 draws them.
Counting uses :x, :y, :weight and :group, and needs :x and :y. A :weight column must
hold numbers, and a missing weight leaves its place's count missing, so no point is drawn there.
The points also take :alpha, :color, :fill, :shape and :size; each is counted over, as
:group is, so a discrete colour gives each of its values at a place a point of its own, and a
mapped :size sizes the points by its column instead of the count. A row missing its x or y
is not counted.
Counting computes n and prop, the count's share of its group's total in its panel, which a
mapping reads with an after_stat (Giggly.Mapping): %{size: {:after_stat, [:prop]}, group: 1}
sizes each point by its share of all the rows.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:sum.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"cty" => [18, 18, 21], "hwy" => [29, 29, 29]} ...> |> Giggly.Plot.new(%{x: :cty, y: :hwy}) ...> |> Giggly.Plot.geom_count() iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :n) [2.0, 1.0] iex> Giggly.DataFrame.pull(frame, :size) [6.0, 1.0]
@spec geom_crossbar(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of crossbars: a box for each row from its ymin to its ymax, with a line across
it at its y, for a value and the interval round it, or, turned, a box from its xmin to its
xmax with a line up it at its x.
Crossbars use a line range's aesthetics, :fill and :width, and need :x and :y and the
range a line range runs along, as geom_linerange/3 takes it. Each box is as wide as the row's
width, as geom_errorbar/3 sizes its whiskers. Every box is drawn before every line across,
which is 2.5 times as wide as the box's border unless middle_linewidth: says otherwise; the
box's fill takes the row's alpha, its border and line across their colour's own. The
middle_ and box_ options give the line across and the box's border a look of their own.
Raises ArgumentError when the plot is run where the layer lacks one of the three positions
its boxes run along, and where a mapped :width is not a number.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which way each range runs::x, up the panel fromymintoymaxat eachx, or:y, across it fromxmintoxmaxat eachy; when not given,:ywhere the layer is given neither:yminnor:ymax, and:xotherwise.:width- How wide every mark is, in the units of the axis it is placed along, x, or y for one that runs across the panel, any number; 0.9 of the closest spacing of the positions there when not given, 0.9 on a discrete axis. It replaces a mapped:width.:alpha- How opaque every box's fill is, from 0, invisible, to 1, opaque; its lines keep their colour's own alpha.:color- The colour of every box's border and line across, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every box is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:linewidth- How wide every box's border is, in millimetres, its line across 2.5 times as wide; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every box's border and line across::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:middle_color- The colour of the line across each box, writtenmiddle_colour:ormiddle_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the crossbar's colour when not given.:middle_linetype- The line type of the line across each box::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the crossbar's when not given.:middle_linewidth- How wide the line across each box is drawn, in millimetres; the crossbar's line width when not given, times 2.5.:box_color- The colour of the box's border, writtenbox_colour:orbox_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the crossbar's colour when not given.:box_linetype- The line type of the box's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; the crossbar's when not given.:box_linewidth- How wide the box's border is drawn, in millimetres; the crossbar's line width when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a box's border turns a corner: pointed (:mitre), rounded (:round) or cut off (:bevel); pointed when not given, and in a legend's keys the glyph's own: pointed for a crossbar's, rounded for a time series'.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"trt" => [1, 2], "resp" => [1.0, 3.0], "lower" => [0.8, 2.4], "upper" => [1.1, 3.3]} ...> |> Giggly.Plot.new(%{x: :trt, y: :resp}) ...> |> Giggly.Plot.geom_crossbar(%{ymin: :lower, ymax: :upper}, middle_colour: "red") ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)} {[0.55, 1.55], [1.45, 2.45]}
@spec geom_curve(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of curves: a curved line for each row, from its x and y to its xend and
yend, for an arrow pointing at a mark or a link that should not cross the points between its
ends.
Curves use :x, :y, :xend, :yend, :group, :alpha, :color, :linetype and
:linewidth, and need all four positions. A row missing a position, its width or its line type
draws no curve, and an infinite position reaches the panel's edge. Each curve takes its own row's
colour, alpha, width and line type; a colour of :none draws none, and so does the line type
:blank, though a blank curve's closed arrowhead is still filled.
curvature: says how far each curve bends and to which side, angle: how its bend leans towards
its start or its end, and ncp: how many control points it runs through. Its shape is worked
out in points as it is drawn, so a curve keeps its shape whatever the panel's. Where an axis runs
backwards (scale_x_reverse/2, coord_cartesian/2's reverse:), each curve is drawn from its
end to its start, so it bends to the same side of the data. arrow: puts an arrowhead on each
curve, in its colour, width and line type, a closed one filled with its colour or the arrow's
fill: at its alpha.
Raises ArgumentError when the plot is drawn under coord_radial/2 or coord_transform/2,
whose straight lines bend, and for a curve whose start and end are in one place.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:curvature- How far each curve bends: its control points lie along a circular arc that turns through 4·atan(|curvature|), a semicircle at 1, bending to the right of its way from start to end where positive and to the left where negative; 0 draws a straight line. The default value is0.5.:angle- How the control points are skewed, in degrees: below 90 towards each curve's start, above it towards its end. Less than a degree from a whole number of half turns draws a straight line. The default value is90.0.:ncp(non_neg_integer/0) - How many control points each curve runs through; more give a rounder curve, and 0 a straight one. The default value is5.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x1" => [2.62], "y1" => [21.0], "x2" => [3.57], "y2" => [15.0]} ...> |> Giggly.Plot.new(%{x: :x1, y: :y1, xend: :x2, yend: :y2}) ...> |> Giggly.Plot.geom_curve(curvature: -0.2) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :yend)} {[2.62], [15.0]}
A curve with an arrowhead is drawn as a polyline, its head after it:
iex> svg =
...> %{"x1" => [2.62], "y1" => [21.0], "x2" => [3.57], "y2" => [15.0]}
...> |> Giggly.Plot.new(%{x: :x1, y: :y1, xend: :x2, yend: :y2})
...> |> Giggly.Plot.geom_curve(arrow: true)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ "<polyline points="
true
@spec geom_density(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of densities: for each group, a smoothed estimate of how its rows are distributed
along x, a smoothed histogram drawn as a curve over the area beneath it, for a variable that
comes from a smooth distribution.
Each curve is a kernel density estimate: a kernel, a normal curve unless kernel: says
otherwise, put at each row and summed, its spread the bandwidth, bw: times adjust:, so a
narrower one follows the rows more closely. Each row weighs as its :weight where one is mapped,
the weights taking their share of their group's total. A curve spans the whole x axis, short of
its widening, at n: evenly spaced places, so curves of different groups share their places,
unless trim: true keeps each to its own group's extent. With bounds:, rows outside them are
left out, and the part of a curve beyond a finite bound is folded back inside it.
Densities use :x or :y, :weight, :group, :alpha, :fill, :color, :linetype and
:linewidth, and need exactly one of :x and :y: the curve runs along the one mapped, so
mapping :y alone draws curves that run up the panel. A :weight column must hold numbers. Each
curve is outlined along its top in the theme's ink and left unfilled unless a fill is mapped or
set; curves are drawn over one another unless position: :stack piles them. A row missing its
x, or at an infinite one, is left out. A group of fewer than two rows is a single row of
missing values, drawn as nothing. A panel where some group's weight is missing, infinite or
below 0, or adds up to 0, or where a rule gives no bandwidth above 0, as for rows all at one
x, is drawn nothing.
A density computes each place's density; count, the density times the group's rows, whose
curves add up when stacked; wdensity, the density times the group's total weight; scaled and
ndensity, the density over the group's greatest; and n, the group's rows, which a mapping
reads with an after_stat (Giggly.Mapping): %{x: :carat, y: {:after_stat, [:count]}, fill: :cut} with position: :stack piles each cut's curve to the density of every diamond. The y
axis is titled density unless something else is mapped there.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:density.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:outline_type- Which of each band's edges its outline draws: the upper and the lower, each a line (:both), the upper alone (:upper), the lower alone (:lower), or the band's whole border (:full). The default value is:upper.:bw- How smooth each curve is, its bandwidth, the kernel's standard deviation in the axis's transformed units: a number above 0, or a rule worked out from each group's rows, taking no weight: Silverman's rule of thumb (:nrd0), 0.9 times the lesser of the rows' standard deviation and their interquartile range over 1.34, times the rows to the power -0.2, or Scott's variation of it (:nrd), 1.06 times the lesser. The default value is:nrd0.:adjust- A multiple of the bandwidth, above 0:adjust: 0.5halves it, for a curve that follows the rows more closely, andadjust: 2doubles it, for a smoother one. The default value is1.0.:kernel- The shape put at each row and summed, scaled so its standard deviation is the bandwidth: a normal curve (:gaussian), a parabola (:epanechnikov), a block (:rectangular), a tent (:triangular), a parabola squared (:biweight), or a cosine's hump (:cosine) or a narrower one (:optcosine). The default value is:gaussian.:n(pos_integer/0) - How many evenly spaced places each curve is worked out at, twice as many with one finite bound and three times with two. The default value is512.:trim(boolean/0) - Whether each curve spans only its own group's extent rather than the panel's axis, short of its widening; trimmed curves no longer share their places, so they do not stack. The default value isfalse.:bounds- Limits the rows are known to lie within,{low, high}, the low a number or:neg_infinity, the high a number or:infinity, not below the low: the rows outside them are left out, and each curve's part beyond a finite one is folded back inside it, so the curve does not spill past a limit the data cannot. The default value is{:neg_infinity, :infinity}.:orientation- The axis the layer runs along,:xor:y, which must be the one of:xand:ymapped; it runs along that one when this is not given.:alpha- How opaque every curve's fill is, from 0, invisible, to 1, opaque; its outline keeps its colour's own alpha.:color- The colour of every curve's outline, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's ink, black, when not given.:fill- The colour every curve is filled with down to 0: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:linewidth- How wide every curve's outline is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every curve's outline::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 4.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.geom_density(n: 3) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :n)} {[1.0, 2.5, 4.0], [4, 4, 4]}
@spec geom_density_2d(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of a two-dimensional density's contour lines: for each group, a density of its
:x and :y estimated on a grid, as a smooth surface of where the rows lie thickest, and the
lines along which it stands at each of a set of levels, drawn as geom_contour/3 draws them.
The estimate is MASS's kde2d(): at each point of a grid, n: points along each axis across
the panel's range, the sum over the group's rows of a normal kernel along each axis, each a
quarter of its axis's bandwidth wide. Each bandwidth is h:, or else MASS's
bandwidth.nrd() of the group's rows, times adjust:. A row missing its x or y, or at
an infinite one, is left out; a panel where a bandwidth comes to no number above 0, as a group
of one row's does, is drawn empty.
The contour levels are those of geom_contour/3, over the range of contour_var: across the
whole layer, so faceted panels share them. With contour: false the layer is the grid itself,
a row at each of its points.
A 2D density uses :x, :y and :group, and needs :x and :y. Its lines also take
:alpha, :color, :linetype and :linewidth, drawn in the theme's accent, #3366FF by
default, unless a colour is mapped or set.
Contoured, the layer computes each line's level, nlevel and piece, as contour lines do,
and n, its group's rows; as a grid, each point's density, ndensity (over its group's
highest), count (the density times its group's rows), n, and a level and piece of 1. A
mapping reads them with an after_stat (Giggly.Mapping), only those the layer computes.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:density_2d.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:contour_var- Which of the grid's columns is contoured::density,:ndensity, the density over its group's highest, or:count, the density times its group's rows. The default value is:density.:h- The bandwidth along each axis, a number above 0 for both or{across, up}, in the axes' units; MASS'sbandwidth.nrd()of each group's rows, timesadjust:, when not given.:adjust- How many times the rule's bandwidth each axis's is, a number above 0 for both or{across, up}; it does not changeh:. The default value is1.0.:n- How many grid points the density is estimated at along each axis, a whole number above 0 for both or{across, up}. The default value is100.:bins(pos_integer/0) - How many contour breaks there are, evenly spaced over the range of the contoured column, which takes the place ofbinwidth:.:binwidth- How far apart the contour breaks are, a number above 0 in the contoured column's units; a tenth of its range when a breaks function is given alone.:breaks- The contour breaks: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of the contoured column's range,{low, high}, and a bin width, returning the breaks; R'spretty()of the range, about ten, when none of them is given.:contour(boolean/0) - Whether the grid is contoured:truedraws its contour lines,falsethe grid itself, a row at each of its points. The default value istrue.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> GigDatasets.faithful() ...> |> Giggly.Plot.new(%{x: :eruptions, y: :waiting}) ...> |> Giggly.Plot.geom_density_2d(contour: false, n: 20) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.row_count(frame) 400 iex> frame |> Giggly.DataFrame.pull(:n) |> Enum.uniq() [272]
@spec geom_density_2d_filled(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of a two-dimensional density's contour bands: the estimate geom_density_2d/3
makes, banded between consecutive levels as geom_contour_filled/3 bands a surface, each band
filled by its level unless a fill is mapped or set.
It uses :x, :y and :group, needs :x and :y, and takes geom_polygon/3's looks. It
computes each band's level, level_low, level_high, level_mid and nlevel, as contour
bands do, and n, its group's rows.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:density_2d_filled.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:contour_var- Which of the grid's columns is contoured::density,:ndensity, the density over its group's highest, or:count, the density times its group's rows. The default value is:density.:h- The bandwidth along each axis, a number above 0 for both or{across, up}, in the axes' units; MASS'sbandwidth.nrd()of each group's rows, timesadjust:, when not given.:adjust- How many times the rule's bandwidth each axis's is, a number above 0 for both or{across, up}; it does not changeh:. The default value is1.0.:n- How many grid points the density is estimated at along each axis, a whole number above 0 for both or{across, up}. The default value is100.:bins(pos_integer/0) - How many contour breaks there are, evenly spaced over the range of the contoured column, which takes the place ofbinwidth:.:binwidth- How far apart the contour breaks are, a number above 0 in the contoured column's units; a tenth of its range when a breaks function is given alone.:breaks- The contour breaks: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of the contoured column's range,{low, high}, and a bin width, returning the breaks; R'spretty()of the range, about ten, when none of them is given.:alpha- How opaque every shape's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every shape's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every shape is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, each band is filled by its level, through the fill scale.:linewidth- How wide every shape's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every shape's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:rule- How a shape of several rings, each asubgroup, is filled::evenoddleaves out what an even number of its rings surround, so a ring inside another is a hole;:windingfills whatever its rings wind round. The default value is:evenodd.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> GigDatasets.faithful() ...> |> Giggly.Plot.new(%{x: :eruptions, y: :waiting}) ...> |> Giggly.Plot.geom_density_2d_filled(n: 20, bins: 3) ...> |> Giggly.layer_data() iex> frame |> Giggly.DataFrame.pull(:level) |> Enum.uniq() |> length() 3
@spec geom_dotplot(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of dots stacked over the bins of x, or of y with binaxis: :y, a dot plot: each
row a dot, as wide as its bin, stacked across the axis with the others in its bin, so the stacks
show how the values are spread. By dot density, the default, the bins fall where the data put
them: sorted along the axis, the first bin starts at the lowest value and runs binwidth: from
there, and each later one starts at the first value past the end of the one before, its dots
stacked halfway between its lowest and highest value; with method: :histodot the axis is cut
into fixed bins, as a histogram's are, each stack at its bin's middle. Every group in every
panel is binned on its own, unless binpositions: :all bins each panel's groups together.
Binned along x, the stacks run up y from 0, or from the group's level where y is mapped to a
discrete column, and the y axis is titled count and runs from 0 to 1, a stack's height in the
data meaning nothing: a dot is as tall as it is wide, whatever the panel's shape, so a tall stack
runs past the panel's top. Binned along y, the stacks run along x from each group's x, the
middle of its values of x where they differ, so :x is needed too, often a constant or a
discrete column. stackdir: turns or centres the stacks, stackratio: draws a stack's dots
together or apart, dotsize: widens or narrows every dot, and stackgroups: true stacks the
groups' dots in a bin on one another.
A row missing a value it maps, its fill or colour as much as its x or weight, is left out,
and so is a row at an infinite x or weight; binned along y by dot density, an infinite y
stacks at the panel's edge, and in fixed bins it is left out.
Dot plots use :x, :y, :group, :weight, :alpha, :color, :fill and :linetype, and
need :x, and :y binned along y. Binned along x, a mapped :y must be on a discrete axis, or
the plot is refused when run, since no dot would sit at it. A :weight column must hold numbers,
and a row's weight counts it that many times, a number of dots, so each row binned must weigh a
whole number from 0 to 2^52, or the plot is refused when run. Each dot is outlined and filled
in the theme's ink unless a look is mapped or set, and a legend's key is one such dot in the
middle of the key, outlined 0.75 points wide whatever stroke: says. A dot is as wide
as its bin along a straight axis, so a dot plot is refused when drawn in coordinates that are
not linear, such as coord_radial/2's.
Binning computes, for each bin, x (or y binned along y), its middle; binwidth; count,
its rows or the sum of their weights; ncount, the count over the group's largest; and in fixed
bins density, the count over the bin's width and the group's total, and ndensity, the
density over the group's largest, which a mapping reads with an after_stat (Giggly.Mapping).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the stacks are moved once the stat has run: left at their places (:identity), set side by side within the width one stack's box takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. Stacking and filling are refused:stackgroups: truestacks the groups' dots. The default value is:identity.:binaxis- The axis the dots are binned along,:xor:y; the stacks run across it, up y from bins along x, along x from bins up y. The default value is:x.:method- How the axis is binned: by dot density (:dotdensity), each bin starting where the data do and no wider thanbinwidth:, or in fixed bins (:histodot), cut as a histogram's are. The default value is:dotdensity.:binwidth- The widest a bin may be by dot density, every bin's width in fixed bins, a number above 0 in the axis's transformed units, which is also every dot's width unlessdotsize:changes it; a thirtieth of the axis's extent when not given, by dot density, or as wide as 30 fixed bins spanning it.:binpositions- Where bins by dot density fall: each group's where its own data put them (:bygroup), or every group's where the panel's data put them (:all), so the groups' stacks line up;:bygroupwhen not given, and refused besidemethod: :histodot, whose bins line up whatever it says.:origin- Where a fixed bin starts, any number in the axis's transformed units, so every bin's edge falls a whole number of bin widths from it; half a bin width when not given. Taken besidemethod: :histodotalone, as dot density's bins start where the data do.:right(boolean/0) - Whether each fixed bin holds a value on its right edge (true) or on its left (false);truewhen not given. Taken besidemethod: :histodotalone.:drop- Whether a bin of no dots is left out of the binning,falsealone: a bin of no dots draws none either way.:stackdir- Which way each stack runs from its bin::up,:down, centred on it (:center), or centred with the dots of every stack in line (:centerwhole); along x from bins up y,:upis to the right. The default value is:up.:stackratio- How far apart a stack's dots are, in dots, 0 or more: 1 just touching, less overlapping, 0 all on the first. The default value is1.0.:dotsize- How wide every dot is, in bin widths, a number above 0. The default value is1.0.:stackgroups(boolean/0) - Whether the groups' dots in a bin stack on one another, in group order, rather than each group's from the bin's start; besidebinpositions: :allormethod: :histodotthe groups' bins line up, as stacking them needs. The default value isfalse.:width- How far each stack's box reaches across a bin up y, any number in the x axis's units, which dodging sets side by side and the x axis spans; 0.9 when not given. Taken besidebinaxis: :yalone, as along x a stack's box is its bin.:alpha- How opaque every dot is, its outline and its fill, from 0, invisible, to 1, opaque.:color- The colour every dot is outlined in, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's ink, black, when not given.:fill- The colour every dot is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's ink, black, when not given.:stroke- How heavy every dot's outline is, in line-width units, as R'slwd; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes.:linetype- The line type of every dot's outline::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 1.5, 2.0, 3.5]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.geom_dotplot(binwidth: 1) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [1.25, 1.25, 2.0, 3.5] iex> Giggly.DataFrame.pull(frame, :stackpos) [0.5, 1.5, 0.5, 0.5]
Centred stacks of fixed bins, binned along y:
iex> frame =
...> %{"y" => [1.0, 1.5, 2.0, 3.5]}
...> |> Giggly.Plot.new(%{x: {:constant, 1}, y: :y})
...> |> Giggly.Plot.geom_dotplot(
...> binaxis: :y,
...> method: :histodot,
...> binwidth: 1,
...> stackdir: :center
...> )
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :y)
[1.0, 1.0, 2.0, 3.0]
iex> Giggly.DataFrame.pull(frame, :stackpos)
[-0.5, 0.5, 0.0, 0.0]
@spec geom_errorbar(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of error bars: a vertical line for each row from its ymin to its ymax at its
x, with a whisker across each end, for an interval round a value, or, turned, a horizontal
one from its xmin to its xmax at its y.
Error bars use a line range's aesthetics and :width, and run up or across the panel as
geom_linerange/3's ranges do. Each whisker is as wide as the row's width, mapped or set, or
else 0.9 of the closest spacing of the positions along the axis the bars are placed on, so bars
at neighbouring positions never meet. A row missing a position draws none of its lines that
need it, and each bar takes its own row's colour, alpha, width and line type.
Raises ArgumentError when the plot is run where the layer lacks one of the three positions
its bars run along, and where a mapped :width is not a number.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which way each range runs::x, up the panel fromymintoymaxat eachx, or:y, across it fromxmintoxmaxat eachy; when not given,:ywhere the layer is given neither:yminnor:ymax, and:xotherwise.:width- How wide every mark is, in the units of the axis it is placed along, x, or y for one that runs across the panel, any number; 0.9 of the closest spacing of the positions there when not given, 0.9 on a discrete axis. It replaces a mapped:width.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"trt" => [1, 2], "resp" => [1.0, 3.0], "lower" => [0.8, 2.4], "upper" => [1.1, 3.3]} ...> |> Giggly.Plot.new(%{x: :trt, y: :resp}) ...> |> Giggly.Plot.geom_errorbar(%{ymin: :lower, ymax: :upper}, width: 0.2) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)} {[0.9, 1.9], [1.1, 2.1]}
@spec geom_freqpoly(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of frequency polygons: the x axis cut into bins, as geom_histogram/3 cuts it,
and for each group a line through the middle of each bin at the number of rows in it, or, where
:weight is mapped, the sum of their weights. A bin of no rows is added at each end, so every
line starts and ends at 0. The y axis is titled count. The lines of different groups are drawn
over one another, not stacked, so a discrete colour compares the groups' distributions. A row
missing its x, or outside the breaks given, is not counted. The lines are drawn as
geom_path/3 draws paths.
Binning uses :x or :y, :weight and :group, and needs exactly one of :x and :y, on a
continuous axis: it bins along the one mapped, so mapping :y alone draws lines that run up the
panel. A :weight column must hold numbers, and a missing weight adds nothing. The lines also
take :alpha, :color, :linetype and :linewidth; one reaches a line only where it is the
same in every row of its group, so a discrete one groups the rows and gives each group its line.
Binning computes what geom_histogram/3 lists, which a mapping reads with an after_stat
(Giggly.Mapping): %{x: :price, y: {:after_stat, [:density]}, color: :cut} draws each cut's
density, comparable however many rows each cut has.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:bin.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins- How many bins span the axis, when neitherbinwidth:norbreaks:is given, a whole number above 0, or a function handed a group's values that returns one. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own. The default value is30.:binwidth- How wide each bin is, a number above 0 in the axis's transformed units, or a function handed a group's values that returns one, which takes the place ofbins:. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own.:center- Where one bin's middle falls, which places them all; not withboundary:.:boundary- Where two bins meet, which places them all; not withcenter:. Without either, the outermost bins are centred on the axis's limits, or binsbinwidth:wide meet half a width from 0.:breaks- Where the bins meet, a list of two or more distinct numbers in the data's units, put through the axis's transformation, or a function handed a group's values that returns them, which takes the place ofbins:,binwidth:,center:andboundary:; a row outside them is not counted. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own.:closed- Which end of a bin a value on its edge belongs to: the right end (:right), or the left (:left); the outermost bins hold their outer ends too. The default value is:right.:drop- Which bins of no rows to leave out: none (:none), every one (:all), or those before the first bin with rows and after the last (:extremes). The default value is:none.:orientation- The axis the layer runs along,:xor:y, which must be the one of:xand:ymapped; it runs along that one when this is not given.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"x" => [1.0, 1.5, 2.5, 4.0]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.geom_freqpoly(binwidth: 1, boundary: 0) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [0.5, 1.5, 2.5, 3.5, 4.5] iex> Giggly.DataFrame.pull(frame, :count) [0.0, 2.0, 1.0, 1.0, 0.0]
@spec geom_function(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer drawing a function of x: its value at n: evenly spaced places along the x
axis, joined by a line, for a density, a fitted curve or a formula drawn over the data, or
alone on a plot with no data (new/0).
The places run across the x axis's extent, the one the other layers' data or the plot's x scale
gives it, or from 0 to 1 where nothing puts a scale on the x axis, unless xlim: gives them.
The function is called at each place in data units and its value put through the y axis's
scale, so under scale_x_log10/1 it is called at the axis's powers and under scale_y_log10/1
its logarithm is drawn. Each group in each panel is a curve of its own, each across the whole
axis: on a plot whose data a discrete aesthetic groups, or under a facet, a curve is drawn for
every group in every panel, from the plot's data; on a plot with no data, one, in every panel.
A place where the function returns nil or :nan breaks the line; an infinite value runs it to
the panel's edge.
A function's layer uses :group and the aesthetics its geom draws with, and needs none; it
works x and y out itself, drawn as geom_path/3 draws a line unless geom: says otherwise.
A column it maps is read from its own data: or the plot's, and refused where neither has data.
The layer computes each place's x and y, which a mapping reads with an after_stat
(Giggly.Mapping): %{colour: {:after_stat, [:y]}} colours the line by its value. The axes are
titled x and y unless something else is mapped there.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:function.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:function, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:function.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:fun(function of arity 1) - Required. The function drawn, of one x, called at each place in data units, so on a log x axis at its powers. It returns the y there: a number,nilfor none,:infinity,:neg_infinityor:nan; anything else fails when the plot is run. Its arguments are its closure's:fn x -> dnorm.(x, 2, 0.5) end.:n(non_neg_integer/0) - How many evenly spaced places the function is called at, none for 0. The default value is101.:xlim- Where the places run,{from, to}, two finite numbers in either order, in the x axis's transformed positions, so on a log10 axis{1, 2}runs from 10 to 100; when not given, across the x axis's extent, or from 0 to 1 where nothing else puts a scale on the x axis.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given, the area's included.
Raises ArgumentError when the plot is run for a value fun: returns that is not one it
takes, naming the value and its x; a raise in fun: propagates. NimbleOptions.ValidationError for an option the geom does not take, or a value it
cannot use: fun: must take one argument.
iex> frame =
...> Giggly.Plot.new()
...> |> Giggly.Plot.geom_function(fun: fn x -> x * x end, n: 5)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :x)
[0.0, 0.25, 0.5, 0.75, 1.0]
iex> Giggly.DataFrame.pull(frame, :y)
[0.0, 0.0625, 0.25, 0.5625, 1.0]
@spec geom_hex(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of hexagons counting the rows in each, hexagonal binning: the plane cut into
hexagons, each standing on a point, and for each group one hexagon wherever a row falls, filled
by how many rows fall in it, or, where :weight is mapped, by the sum of their weights. A
heatmap of two continuous variables, it shows where many rows overlap, as points drawn over
one another cannot.
The hexagons are 30 across each panel's x and y axes unless bins: or binwidth: says
otherwise; each group's hexagons start from its own rows, so groups are binned apart. A row
falls in the hexagon whose centre is nearest. A row missing its x or y, or at an infinite
one, is not counted. A panel where an axis has no extent, as for rows all at one x, is drawn
nothing.
Hexagonal binning uses :x, :y, :weight and :group, and needs :x and :y. A :weight
column must hold numbers. The hexagons also take :alpha, :fill, :color, :linetype and
:linewidth; one reaches a hexagon only where it is the same in every row of its group, so a
discrete one groups the rows. Each is filled by its count through the fill scale, which titles
the legend count, unless a fill is mapped or set, and drawn without a border unless a colour
is mapped or set.
Hexagonal binning computes, for each hexagon, count; density, the count over the group's
total; and ncount and ndensity, the count and the density over the group's largest. A
mapping reads them with an after_stat (Giggly.Mapping): %{x: :carat, y: :price, fill: {:after_stat, [:density]}} fills each hexagon by its share of the rows.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:bin_hex.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins- How many hexagons span each axis, whenbinwidth:is not given: a whole number above 0 for both, or{x_bins, y_bins}. The default value is30.:binwidth- How wide and how high each hexagon is, in the axes' transformed units, which takes the place ofbins:: a number above 0 for both, or{width, height}.:alpha- How opaque every hexagon's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every hexagon's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every hexagon is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, each hexagon is filled by its count, through the fill scale.:linewidth- How wide every hexagon's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every hexagon's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a border turns a corner: pointed (:mitre), rounded (:round) or cut off (:bevel). The default value is:mitre.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [0.0, 0.1, 1.0, 2.0], "y" => [0.0, 0.1, 1.0, 2.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_hex(binwidth: 1) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :count) [2.0, 1.0, 1.0]
@spec geom_histogram(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of bars counting the rows in each bin, a histogram: the x axis cut into bins, and
for each group one bar per bin, from 0 to the number of rows in it, or, where :weight is
mapped, to the sum of their weights, a bin with no rows counting 0. The y axis is titled count.
The bins are 30 spanning each panel's x axis unless bins:, binwidth: or breaks: says
otherwise; bars of different groups in one bin are stacked. A row missing its x, or outside the
breaks given, is not counted. The bars are drawn as geom_col/3 draws them.
Binning uses :x or :y, :weight and :group, and needs exactly one of :x and :y, on a
continuous axis: it bins along the one mapped, so mapping :y alone draws horizontal bars. A
:weight column must hold numbers, and a missing weight adds nothing. The bars also take
:alpha, :fill, :color, :linetype and :linewidth; one reaches a bar only where it is the
same in every row of its group, so a discrete one groups the rows and gives each group its bars.
Binning computes, for each bin, count; density, the count over the bin's width over the
group's total, so a group's bars cover an area of 1; ncount and ndensity, the count and the
density over the group's largest; and width. A mapping reads them with an after_stat
(Giggly.Mapping): %{x: :hwy, y: {:after_stat, [:density]}} draws the density.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:bin.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:stack.:bins- How many bins span the axis, when neitherbinwidth:norbreaks:is given, a whole number above 0, or a function handed a group's values that returns one. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own. The default value is30.:binwidth- How wide each bin is, a number above 0 in the axis's transformed units, or a function handed a group's values that returns one, which takes the place ofbins:. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own.:center- Where one bin's middle falls, which places them all; not withboundary:.:boundary- Where two bins meet, which places them all; not withcenter:. Without either, the outermost bins are centred on the axis's limits, or binsbinwidth:wide meet half a width from 0.:breaks- Where the bins meet, a list of two or more distinct numbers in the data's units, put through the axis's transformation, or a function handed a group's values that returns them, which takes the place ofbins:,binwidth:,center:andboundary:; a row outside them is not counted. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own.:closed- Which end of a bin a value on its edge belongs to: the right end (:right), or the left (:left); the outermost bins hold their outer ends too. The default value is:right.:pad(boolean/0) - Whether to add a bin of no rows at each end. The default value isfalse.:drop- Which bins of no rows to leave out: none (:none), every one (:all), or those before the first bin with rows and after the last (:extremes). The default value is:none.:orientation- The axis the layer runs along,:xor:y, which must be the one of:xand:ymapped; it runs along that one when this is not given.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every bar's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every bar is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 35% toward its paper,#595959, or#000000A6undertheme_void/2, whose paper is clear.:linewidth- How wide every bar's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every bar's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"x" => [1.0, 1.5, 2.5, 4.0]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.geom_histogram(binwidth: 1, boundary: 0) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :count) [2.0, 1.0, 1.0] iex> Giggly.DataFrame.pull(frame, :x) [1.5, 2.5, 3.5]
@spec geom_hline(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of horizontal reference lines: a line across the whole panel at each yintercept,
for a threshold, a target or a mean drawn over the data.
The lines are given in one of two ways. yintercept: gives them as values, a line for each,
drawn in every panel and in no legend. Or the layer maps :yintercept from a table, its own
data: or the plot's, so the lines can differ from panel to panel under a facet and map a
colour, alpha, width or line type into a legend. Either way the layer takes nothing from the
plot's mapping, and titles no axis.
Horizontal lines use :yintercept, :group, :alpha, :color, :linetype and :linewidth,
and need :yintercept, which the y axis widens to show and puts through its scale as it does
y: a number on a continuous axis, a string on a discrete one, a date, a date-time or a time
on such an axis, and :infinity or :neg_infinity at the panel's edge. A line repeated in a
panel is drawn once. Beside yintercept:, each look option takes one value or a list, one per
line, every list as long as the others. A line missing its yintercept, as a scale's limits
leave it, draws nothing, and so do a colour of :none and the line type :blank. Under
coord_radial/2 each line is a circle, or a spoke from the centre under theta: :y.
Raises ArgumentError for yintercept: beside a mapping or data:, for a list of looks
without yintercept:, and for lists of different lengths.
Options
:data(term/0) - A table for the layer's mapping to draw from instead of the plot's data, anything implementingTable.Reader; refused beside the options giving lines as values, which draw lines of their own. Under a facet, a table lacking a faceting column is drawn in every panel.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added. Taken only beside a mapping.:position- Where the lines are moved: left where they cross the axis (:identity), or nudged (:nudge), as Positions says. The default value is:identity.:yintercept- Where each line crosses the y axis, in its units: a value, or a list of them, a line for each, drawn in every panel. Given, the layer takes no mapping and nodata:.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:alpha- How opaque each line is, from 0, invisible, to 1, opaque.:color- The colour of each line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide each line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of each line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.iex> frame = ...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.geom_hline(yintercept: [20, 25], colour: ["red", "blue"]) ...> |> Giggly.layer_data(1) iex> {Giggly.DataFrame.pull(frame, :yintercept), Giggly.DataFrame.pull(frame, :color)} {[20.0, 25.0], ["#FF0000", "#0000FF"]}
A line for each panel, mapped from a table of its own:
iex> frame =
...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7], "cyl" => [4, 8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.geom_hline(%{yintercept: :mean},
...> data: %{"cyl" => [4, 8], "mean" => [26.7, 15.1]}
...> )
...> |> Giggly.Plot.facet_wrap(:cyl)
...> |> Giggly.layer_data(1)
iex> {Giggly.DataFrame.pull(frame, :yintercept), Giggly.DataFrame.pull(frame, :panel)}
{[26.7, 15.1], [1, 2]}
@spec geom_jitter(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of points, as geom_point/3 adds, each moved a small random distance across and up
from its place, so that points sharing a place stand apart: by up to 0.4 of the closest spacing
of each panel's positions either way, 0.4 on a discrete axis, whose levels are 1 apart, unless
width: and height: say how far. The axes widen to hold the points where they land.
The distances are drawn from a seed, so a plot draws the same points every time it is drawn, and
two layers of the same rows move them alike; position: {:jitter, seed: seed} draws
others. Each panel draws its distances afresh from the seed.
Points use the aesthetics geom_point/3's use, and need :x and :y. Raises ArgumentError
when position: is given beside width: or height:.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:width- How far each point moves at most to either side, in the units of the x axis, 0 or more; 0.4 of the closest spacing of each panel'sxpositions when not given, 0.4 on a discrete axis.:height- How far each point moves at most up or down, in the units of the y axis, 0 or more; 0.4 of the closest spacing of each panel'sypositions when not given.:position- Where the points are moved: any position the points ofgeom_point/3take, as Positions says; refused besidewidth:orheight:. They move aswidth:andheight:say when not given.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"cyl" => [4, 4, 6], "hwy" => [29, 29, 26]} ...> |> Giggly.Plot.new(%{x: :cyl, y: :hwy}) ...> |> Giggly.Plot.geom_jitter(height: 0) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [3.969331140393459, 4.786222529919443, 5.4305619806336995] iex> Giggly.DataFrame.pull(frame, :y) [29.0, 29.0, 26.0]
@spec geom_label(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of labels: each row's label at its x and y, as geom_text/3 writes it, on a
box with rounded corners, so it reads over what lies beneath.
Each label is written and justified as geom_text/3's are, its box placed and turned with its
text, padded round it by a quarter of a line of the text on every side and its corners rounded
to 0.15 of a line. A box is white with a black border 0.25 millimetres wide, and its text black
and 11 points tall, unless the options say otherwise; alpha: makes the box see-through, but
neither the text nor the border. Labels are drawn in the order of their rows, each box and then
its text, so a later label covers an earlier one. A row missing its x, y or label draws
nothing.
Labels use :x, :y, :label, :group, :alpha, :color, :fill, :linetype and
:linewidth, and the seven looks geom_text/3 maps (:size, :angle, :hjust, :vjust,
:family, :fontface and :lineheight), read as it reads them, and need :x, :y and
:label; a label never groups the rows. A label breaks over lines as geom_text/3's does, its
box round all of them. A label missing its size is 12 points tall, one missing its family drawn
in the default one, and one missing its line height spaced at 1.2; one missing its angle or
justification, turned an infinite angle, spaced by an infinite line height, or justified by a
word not among the options', raises when the plot is drawn, and so does a face geom_text/3
raises for, its box measured in its face. nudge_x: and
nudge_y: move every label, in the units of each axis, and a mapped :nudge_x or :nudge_y
each its own way, as its position, :nudge unless position: says otherwise, reads them, and
the axes reach each label's place, though not its box. Raises ArgumentError for a nudge
beside another position, which moves no label by it.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:nudge.:size_unit- The unit every label's size is read in, its own or the theme's::mm, each 2.85 points,:pt,:cm,:inor:pc, picas of 12 points. The theme's size is read in it too, 3.87, so a layer that reads sizes in another unit and gives none draws its text 3.87 of that unit tall. A legend's keys read their sizes in millimetres whatever it is. The default value is:mm.:label_with- A function handed each row's label as text, as R'sas.character()writes it, that returns a label another library lays out (Giggly.Label), drawn in the label's place, sized and turned as the row says and justified by its whole box, as R'sparse = TRUEdraws an expression:&GigTypst.math/1. A missing label is not drawn and not handed over; the legend's key is still the letter "a", as R parses none. Not withlineheight:or the:symbolface.:none, the default, draws each label as text. The default value is:none.:alpha- How opaque every label's box is, from 0, invisible, to 1, opaque; its text and border keep their colour's own.:color- The colour of every label's text and border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given. Neither takesalpha:, only its colour's own.:fill- The colour every label's box is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's paper, white, when not given.:linewidth- How wide every label's border is, in millimetres, 0 for none; half the theme'sbase_line_sizewhen not given, 0.25 at its default sizes.:linetype- The line type of every label's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:size- How big every label is, in the unitsize_unit:gives, millimetres unless it says otherwise; the theme'sbase_sizewhen not given, 11 points at its default sizes.:angle- How far every label is turned, in degrees anticlockwise; 0 when not given.:hjust- Where along its baseline every label is anchored on its place, 0 its start and 1 its end: a number from 0 to 1, or one of the words:left,:centerand:right,:bottom,:middleand:top, or:inwardand:outward, which justify each label toward or away from the middle of the panel by where it falls; 0.5 when not given.:vjust- Where up its height every label is anchored on its place, 0 its baseline and 1 the top of a capital letter: a number from 0 to 1, or one of the words:left,:centerand:right,:bottom,:middleand:top, or:inwardand:outward, which justify each label toward or away from the middle of the panel by where it falls; 0.5 when not given.:family(String.t/0) - The font every label is drawn in, by name, such as"Times New Roman", or one of the generic families"sans","serif"and"mono"; the theme'sbase_familywhen not given, the default sans-serif at its default. How a label is measured and drawn in it: the fonts guide.:fontface- The face every label is drawn in::plain,:bold,:italic,:bold_italic, or:symbol, R's symbol font, which writes each letter of a label as a Greek one ("Mg"as"Μγ") and some signs as others (@as≅), and takes only ASCII characters;:plainwhen not given.:lineheight- How far apart the lines of every label are, which breaks at each"\n": any number, each line1.2 * lineheighttimes the label's size below the one before, 0 setting every line on one baseline and a negative one stacking them upward; 1.2 when not given. A legend's keys space their lines 1.2 apart whatever it is.:label_padding- The room round every label's text inside its box: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0; each a number of points or{amount, unit}with a unit of:pt,:cm,:mm,:inor:lines, lines of the label's own text. The text sits the bottom's padding above the box's bottom, its descent within it, and the top's is at least the descent. The default value is{0.25, :lines}.:label_r- The radius of every label's box's corners, a length aslabel_padding:takes one; 0 for square corners. The default value is{0.15, :lines}.:border_color- The colour of every label's border apart from its text, writtenborder_colour:orborder_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none, or:color, the label's own colour, when not given. The default value is:color.:text_color- The colour of every label's text apart from its border, writtentext_colour:ortext_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none, or:color, the label's own colour, when not given. The default value is:color.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"wt" => [2.62, 2.32], "mpg" => [21.0, 22.8], "model" => ["Mazda RX4", "Datsun 710"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, label: :model}) ...> |> Giggly.Plot.geom_label(fill: "lightyellow") ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :fill), Giggly.DataFrame.pull(frame, :linewidth)} {["#FFFFE0", "#FFFFE0"], [0.25, 0.25]}
A label is drawn as its box and its text, here padded 4 points either side, on square corners:
iex> svg =
...> %{"x" => [1.0], "y" => [1.0], "name" => ["a"]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, label: :name})
...> |> Giggly.Plot.geom_label(label_padding: [left: 4, right: 4], label_r: 0)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ "<polygon points=", svg =~ ">a</text>"}
{true, true}
@spec geom_line(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of lines: a line through each group's rows in order of their x, as a series over
time is drawn, or of their y with orientation: :y. Rows that share a position keep the order
the data gives them. Lines are drawn as geom_path/3 draws paths and take the same aesthetics.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which position the rows are put in order of:x, oryfor a line that runs up the panel. The default value is:x.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"x" => [1.0, 3.0, 2.0], "y" => [1.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_line() iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [1.0, 2.0, 3.0] iex> Giggly.DataFrame.pull(frame, :y) [1.0, 4.0, 2.0]
@spec geom_linerange(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of line ranges: a vertical line for each row from its ymin to its ymax at its
x, for an interval round a value, or a horizontal one from its xmin to its xmax at its
y.
Line ranges use :x, :y, :xmin, :xmax, :ymin, :ymax, :group, :alpha, :color,
:linetype and :linewidth. A layer given :ymin or :ymax runs up the panel and needs :x,
:ymin and :ymax; one given neither runs across it and needs :y, :xmin and :xmax; and
orientation: chooses either way. A row missing a position, its width or its line type draws no
line, and an infinite end reaches the panel's edge. Each line takes its own row's colour, alpha,
width and line type; a colour of :none draws none, and so does the line type :blank. Under
coord_radial/2 a line follows the panel's curves.
Raises ArgumentError when the plot is run where the layer lacks one of the three positions
its lines run along.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which way each range runs::x, up the panel fromymintoymaxat eachx, or:y, across it fromxmintoxmaxat eachy; when not given,:ywhere the layer is given neither:yminnor:ymax, and:xotherwise.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"trt" => [1, 2], "resp" => [1.0, 3.0], "lower" => [0.8, 2.4], "upper" => [1.1, 3.3]} ...> |> Giggly.Plot.new(%{x: :trt, y: :resp}) ...> |> Giggly.Plot.geom_linerange(%{ymin: :lower, ymax: :upper}) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :ymin), Giggly.DataFrame.pull(frame, :ymax)} {[0.8, 2.4], [1.1, 3.3]}
Ranges given :xmin and :xmax run across the panel:
iex> frame =
...> %{"trt" => [1, 2], "lower" => [0.8, 2.4], "upper" => [1.1, 3.3]}
...> |> Giggly.Plot.new(%{y: :trt, xmin: :lower, xmax: :upper})
...> |> Giggly.Plot.geom_linerange()
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :flipped_aes)
[true, true]
@spec geom_path(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of paths: a line through each group's rows in the order the data gives them, for a
line that may double back. geom_line/3 puts the rows in order first.
Paths use :x, :y, :group, :alpha, :color, :linetype and :linewidth, and need :x
and :y. Each group is a line of its own, and a discrete colour, line type or width groups the
rows. A row missing x or y breaks its line; a group of one row draws nothing. Where colour,
alpha or width changes along a line, each segment takes the colour, alpha and width of the row
it starts from, and a missing width leaves its segment out; a line type cannot change along a
line, and while any line is dashed, dotted or blank, drawing one whose colour, alpha or width
changes raises ArgumentError. A colour of :none draws no line, and so does the line type
:blank, though a blank line's closed arrowheads are still filled.
arrow: puts an arrowhead at a line's ends, in the line's colour, width and line type, its arms
the same length however the panel is sized; a line broken by a missing position has its heads at
the line's own first and last rows, and one drawn as segments only at those ends too.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"unemploy" => [2.9, 4.1, 3.4], "psavert" => [12.6, 9.4, 11.1]} ...> |> Giggly.Plot.new(%{x: :unemploy, y: :psavert}) ...> |> Giggly.Plot.geom_path(linewidth: 2) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [2.9, 4.1, 3.4] iex> Giggly.DataFrame.pull(frame, :linewidth) [2.0, 2.0, 2.0]
A line type is held as its dash pattern, whichever way it is written:
iex> frame =
...> %{"unemploy" => [2.9, 4.1], "psavert" => [12.6, 9.4]}
...> |> Giggly.Plot.new(%{x: :unemploy, y: :psavert})
...> |> Giggly.Plot.geom_path(linetype: 2)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :linetype)
[{4, 4}, {4, 4}]
@spec geom_point(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of points, one per row, at x and y, or each moved a small random distance from
there with position: :jitter, as geom_jitter/3 moves them.
Points use :x, :y, :group, :alpha, :color, :fill, :shape and :size, and need
:x and :y. A point's alpha applies to its colour and its fill alike; a colour or shape of
:none, or a missing size or shape, draws no point.
A point is drawn in one of 26 shapes, each named, and numbered 0 to 25:
- outlined in the point's colour:
:square_open(0),:circle_open(1),:triangle_open(2),:plus(3),:cross(4),:diamond_open(5),:triangle_down_open(6),:square_cross(7),:asterisk(8),:diamond_plus(9),:circle_plus(10),:star(11),:square_plus(12),:circle_cross(13) and:square_triangle(14); - filled with its colour:
:square(15),:circle_small(16),:triangle(17) and:diamond(18), with no outline, and:circle(19) and the smaller:bullet(20), outlined in it too; - outlined in its colour and filled with its fill:
:circle_filled(21),:square_filled(22),:diamond_filled(23),:triangle_filled(24) and:triangle_down_filled(25).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8], "cyl" => ["6", "4"]} ...> |> Giggly.Plot.new() ...> |> Giggly.Plot.geom_point(%{x: :wt, y: :mpg, group: :cyl}) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [2.62, 2.875] iex> Giggly.DataFrame.pull(frame, :group) [2, 1]
A value set for every point is in every row of the layer's table:
iex> plot =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point(alpha: 0.4)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha)
[0.4, 0.4]A colour is kept as the hex it names:
iex> plot =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point(colour: "steelblue")
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color)
["#4682B4", "#4682B4"]A shape given by its number is kept as its name:
iex> plot =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point(shape: 21, fill: "white", size: 5, stroke: 2)
iex> frame = Giggly.layer_data(plot)
iex> {Giggly.DataFrame.pull(frame, :shape), Giggly.DataFrame.pull(frame, :fill)}
{[:circle_filled, :circle_filled], ["#FFFFFF", "#FFFFFF"]}
@spec geom_pointrange(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of point ranges: a line range for each row, as geom_linerange/3 draws one, with
a point at its x and y on it, for a value and the interval round it, such as a mean and its
standard error.
Point ranges use a line range's aesthetics and a point's :fill, :shape, :size and
:stroke, and need :x and :y and the range a line range runs along: :ymin and :ymax
up the panel, or :xmin and :xmax across it, as orientation: or the range given says. Every
line is drawn before every point, each point four times its size, so a small size makes a
plain dot on the line. Each line and point takes its own row's look; a row missing a position
draws no line, and one missing x or y no point.
Raises ArgumentError when the plot is run where the layer lacks one of the three positions
its lines run along.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which way each range runs::x, up the panel fromymintoymaxat eachx, or:y, across it fromxmintoxmaxat eachy; when not given,:ywhere the layer is given neither:yminnor:ymax, and:xotherwise.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:color- The colour of every line and point, writtencolour:orcolor:, which outlines the point's shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres, each drawn four times as big; a third of the theme's points' size when not given, 0.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"trt" => [1, 2], "resp" => [1.0, 3.0], "lower" => [0.8, 2.4], "upper" => [1.1, 3.3]} ...> |> Giggly.Plot.new(%{x: :trt, y: :resp}) ...> |> Giggly.Plot.geom_pointrange(%{ymin: :lower, ymax: :upper}, colour: "red") ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :size), Giggly.DataFrame.pull(frame, :stroke)} {[0.5, 0.5], [1.0, 1.0]}
@spec geom_polygon(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of polygons: each group a shape through its rows in order, closed back to its
first, drawn in the look of its group's first row. A group whose rows carry a :subgroup is
one shape of several rings, one per subgroup, filled together by rule:, so a ring inside
another is a hole. A row missing its x or y is left out, and a layer of a single row draws
nothing.
Polygons need :x and :y, and take :alpha, :color, :fill, :group, :linetype,
:linewidth and :subgroup. A polygon has no border and is filled with the theme's ink mixed a
fifth of the way to its paper unless a colour or a fill is mapped or set.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every shape's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every shape's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every shape is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's ink mixed a fifth of the way to its paper,#333333by default, when not given.:linewidth- How wide every shape's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every shape's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:rule- How a shape of several rings, each asubgroup, is filled::evenoddleaves out what an even number of its rings surround, so a ring inside another is a hole;:windingfills whatever its rings wind round. The default value is:evenodd.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [0.0, 4.0, 4.0, 0.0], "y" => [0.0, 0.0, 4.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_polygon(fill: "steelblue") ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :fill) ["#4682B4", "#4682B4", "#4682B4", "#4682B4"]
@spec geom_qq(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of quantile-quantile points: for each group, its :sample sorted, each value
against the distribution's quantile at the same share of the way through it, so a sample drawn
from the distribution lies along a straight line and its departures show where the two differ.
The value ranked i of n is set against the quantile at (i - a) / (n + 1 - 2a), a 3/8 for a
group of 10 values or fewer and 1/2 past it.
A Q–Q layer uses :sample and :group, and needs :sample, which must hold numbers; a row
missing its sample, or at an infinite one, is left out. The layer works x and y out
itself, so neither may be mapped but by an after_stat. The points take :alpha, :color,
:fill, :shape, :size and :stroke, drawn as geom_point/3 draws them.
The layer computes each point's sample and theoretical quantile, which y and x take
and a mapping reads with an after_stat (Giggly.Mapping); the axes are titled theoretical
and sample unless something else is mapped there. geom_qq_line/3 draws the line the
points would follow.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:point, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:point.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:distribution- The distribution the sample is set against::normal, the standard normal;{:normal, mean: mean, sd: sd}, either left out at 0 and 1, the sd 0 or more;{:t, df: df}, Student's t withdfdegrees of freedom, above 0; or a function of one probability returning the quantile there, a number,nil,:infinity,:neg_infinityor:nan. The default value is:normal.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"s" => [2.1, -0.5, 0.3, 1.7, -1.2]} ...> |> Giggly.Plot.new(%{sample: :s}) ...> |> Giggly.Plot.geom_qq() ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [-1.2, -0.5, 0.3, 1.7, 2.1] iex> frame |> Giggly.DataFrame.pull(:x) |> Enum.map(fn x -> Float.round(x, 6) end) [-1.179761, -0.497201, 0.0, 0.497201, 1.179761]
Against Student's t with 5 degrees of freedom:
iex> frame =
...> %{"s" => [2.1, -0.5, 0.3, 1.7, -1.2]}
...> |> Giggly.Plot.new(%{sample: :s})
...> |> Giggly.Plot.geom_qq(distribution: {:t, df: 5})
...> |> Giggly.layer_data()
iex> frame |> Giggly.DataFrame.pull(:theoretical) |> Enum.map(fn x -> Float.round(x, 6) end)
[-1.339404, -0.529607, 0.0, 0.529607, 1.339404]
@spec geom_qq_line(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of quantile-quantile lines: for each group, the line through two points, the
distribution's quantile against the :sample's at each of two probabilities, line_p:, the
quartiles unless given, so the points geom_qq/3 draws from the same sample lie along it where
the sample follows the distribution. Each line is drawn across the whole panel, as
geom_abline/3 draws one, from its slope and intercept; its two rows in the layer's table
hold its x and y at the least and greatest of the quantiles the points are set against, or
with fullrange: true across the x axis where some other layer maps it or the plot gives it a
scale, and they widen the axes to reach them.
A Q–Q line layer uses :sample and :group, and needs :sample, which must hold numbers; a
row missing its sample, or at an infinite one, is left out. The line takes :alpha, :color,
:linetype and :linewidth, drawn as geom_abline/3 draws them. A probability of 0 or 1,
where the distribution's quantile is infinite, gives a flat line through the other point, or
none where both are, and two equal probabilities give none.
The layer computes each line's x, y, slope and intercept, which a mapping reads with an
after_stat (Giggly.Mapping); the axes are titled x and y unless something else is mapped
there, and a later layer's titles replace those.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:abline, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:abline.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:distribution- The distribution the sample is set against::normal, the standard normal;{:normal, mean: mean, sd: sd}, either left out at 0 and 1, the sd 0 or more;{:t, df: df}, Student's t withdfdegrees of freedom, above 0; or a function of one probability returning the quantile there, a number,nil,:infinity,:neg_infinityor:nan. The default value is:normal.:line_p- The two probabilities,{first, second}, each from 0 to 1, at which the line meets the sample's quantiles against the distribution's; at 0 or 1 the distribution's quantile is infinite, and the line is flat or missing. The default value is{0.25, 0.75}.:fullrange(boolean/0) - Whether the line's data spans the x axis, where some layer maps it or the plot gives it a scale, rather than the distribution's quantiles; the line is drawn across the panel either way. The default value isfalse.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.iex> frame = ...> %{"s" => [2.1, -0.5, 0.3, 1.7, -1.2]} ...> |> Giggly.Plot.new(%{sample: :s}) ...> |> Giggly.Plot.geom_qq_line() ...> |> Giggly.layer_data() iex> frame |> Giggly.DataFrame.pull(:slope) |> Enum.map(fn x -> Float.round(x, 6) end) [1.630862, 1.630862] iex> frame |> Giggly.DataFrame.pull(:intercept) |> Enum.map(fn x -> Float.round(x, 6) end) [0.6, 0.6]
@spec geom_quantile(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of quantile lines: for each group, and for each of a set of quantiles, the line
that best follows that quantile of :y along :x, so that at the median half of the rows lie
above it and half below, as a box plot's middle line does at each place, and at 0.9 nine in
ten below. Each line is worked out at 100 places evenly spaced along the group's x, from its
least to its greatest, and each quantile's line is a group of its own.
method: :rq, the default, fits a straight line, the one minimising the sum over the rows of
each one's distance above it times the quantile plus its distance below it times one less the
quantile. method: :rqss fits a smooth curve instead, straight between the group's distinct
x, minimising the same sum plus lambda: over 2 times how much the curve's slope turns in
all; a larger lambda: makes it straighter. Where more than one line or curve does best, the
one drawn is one of them. A mapped :weight weighs each row's distance.
A row missing its x or y, or at an infinite one, is left out, and a row missing its weight
is left out of the fit. Where a group cannot be fitted, its whole panel draws no lines: for a
straight line, a weight below 0 or infinite, or fewer than two distinct x among the rows
weighted above 0; for a curve, an infinite weight, fewer than three distinct x among the rows
with a weight, or a row missing its weight at the group's least or greatest x.
Quantile lines use :x, :y, :weight and :group, and need :x and :y; a :weight
column must hold numbers. The lines also take :alpha, :color, :linetype and
:linewidth, drawn as geom_path/3 draws a line; one reaches a line only where it is the same
in every row of its group. A line is drawn in the theme's accent, #3366FF by default, unless
a colour is mapped or set.
Quantile lines compute, for each point, quantile, the quantile its line is fitted at, which a
mapping reads with an after_stat (Giggly.Mapping): %{color: {:after_stat, [:quantile]}}
colours each line by its quantile.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:quantile.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:quantiles- The quantiles a line or curve is fitted at, each a number from 0 to 1, in the order drawn; a repeated one is drawn twice. The default value is[0.25, 0.5, 0.75].:method- How each quantile is fitted::rq, a straight line; or:rqss, a smooth curve, straight between each group's distinctx, smoothed bylambda:. The default value is:rq.:lambda- How smooth each:rqsscurve is, a finite number: the larger, the less its slope turns, 0 following the rows at eachx; 1 when not given. Onlymethod: :rqsstakes it.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 3.0, 4.0], "y" => [1.0, 3.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_quantile(quantiles: [0.5]) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.row_count(frame), Enum.uniq(Giggly.DataFrame.pull(frame, :group))} {100, ["-1-0.5"]}
@spec geom_raster(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of equal cells on a regular grid, one per row, drawn as one image: a faster, smaller tile for a surface of values, such as a density over two variables.
Every cell is as wide as the gap between the x positions and as tall as the gap between the
y positions, the smallest where the gaps differ. Positions may skip places, a grid with
holes, but each must be a whole number of cells from the least, or the plot raises when run;
geom_tile/3 draws cells at uneven positions. hjust: and vjust: place each cell against
its position. A row missing its x or y draws nothing, and a place no row fills is left
clear. In radial coordinates the cells are drawn as tiles.
Rasters use :x, :y, :group, :alpha and :fill, and need :x and :y. :fill fills a
cell and takes its alpha; a raster has no border.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:fill- The colour every cell is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:hjust- Where each cell sits across against itsx, a number from 0 to 1: 0 puts the cell's right or top edge there, 1 its left or bottom edge, and 0.5 centres it. The default value is0.5.:vjust- Where each cell sits up against itsy, a number from 0 to 1: 0 puts the cell's right or top edge there, 1 its left or bottom edge, and 0.5 centres it. The default value is0.5.:interpolate(boolean/0) - Whether a viewer blends neighbouring cells' colours, smoothing the image, rather than drawing each cell as a block of its colour. The default value isfalse.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 4.0], "y" => [1.0, 1.0, 1.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_raster(hjust: 0) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)} {[0.0, 1.0, 3.0], [1.0, 2.0, 4.0]}
@spec geom_rect(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of rectangles, one per row, each from its xmin to its xmax and its ymin to its
ymax.
Each corner is mapped to a column, or set for every rectangle by the option of its name, in the
units of its axis; a set corner widens the axes as a mapped one does. :infinity and
:neg_infinity reach the panel's edge, so a band can shade the whole panel. A row missing a
corner draws nothing.
Rectangles use :xmin, :xmax, :ymin, :ymax, :group, :alpha, :fill, :color,
:linetype and :linewidth, and need all four corners, each mapped or set. They look as
geom_col/3's bars do, their borders as wide and dashed as :linewidth and :linetype say.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the rectangles are moved: left at their positions (:identity), set side by side within the width one takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every rectangle's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every rectangle is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 35% toward its paper,#595959, or#000000A6undertheme_void/2, whose paper is clear.:linewidth- How wide every rectangle's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every rectangle's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:xmin- Every rectangle'sxmin, in the units of the x axis: a number, or:infinityor:neg_infinity, which reach the panel's edge.:xmax- Every rectangle'sxmax, asxmin:sets one.:ymin- Every rectangle'symin, in the units of the y axis, asxmin:sets anxmin.:ymax- Every rectangle'symax, asymin:sets one.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"start" => [1.0, 3.0], "end" => [2.0, 5.0], "low" => [0.0, 1.0], "high" => [4.0, 2.0]} ...> |> Giggly.Plot.new(%{xmin: :start, xmax: :end, ymin: :low, ymax: :high}) ...> |> Giggly.Plot.geom_rect() ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :ymax)} {[1.0, 3.0], [4.0, 2.0]}
Corners set for every rectangle shade one band behind every row:
iex> frame =
...> %{"start" => [1.0, 3.0], "end" => [2.0, 5.0]}
...> |> Giggly.Plot.new(%{xmin: :start, xmax: :end})
...> |> Giggly.Plot.geom_rect(ymin: 0, ymax: :infinity)
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :ymin), Giggly.DataFrame.pull(frame, :ymax)}
{[0.0, 0.0], [:infinity, :infinity]}
@spec geom_ribbon(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of ribbons: the band between each group's ymin and ymax along its x, for a
range around a line, or between its xmin and xmax up its y.
Ribbons use :x, :y, :xmin, :xmax, :ymin, :ymax, :group, :alpha, :fill,
:color, :linetype and :linewidth, and need one of :x and :y, one of :ymin and
:xmin, and one of :ymax and :xmax. A band runs along x, or along y where it is given
neither :ymin nor :ymax, or as orientation: says. Each group is a band of its own, its rows
in order along it, and a row missing a position breaks its band there. A band is filled, at its
alpha, and outlined only where a colour is mapped or set, its outline taking no alpha but its
colour's own; its look cannot change along it: a colour, fill, alpha, width or line type that
changes within a group raises ArgumentError when the plot is drawn.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- The axis each band runs along,:xor:y; when not given, along y where the layer is given neither:yminnor:ymax, and along x otherwise. A band along x needs:yminor:ymax, and one along y:xminor:xmax.:outline_type- Which of each band's edges its outline draws: the upper and the lower, each a line (:both), the upper alone (:upper), the lower alone (:lower), or the band's whole border (:full). The default value is:both.:alpha- How opaque every band's fill is, from 0, invisible, to 1, opaque; its outline keeps its colour's own alpha.:color- The colour of every band's outline, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no outline when not given.:fill- The colour every band is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every band's outline is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every band's outline::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [2, 1, 3], "low" => [1.0, 0.5, 2.0], "high" => [3.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, ymin: :low, ymax: :high}) ...> |> Giggly.Plot.geom_ribbon() ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :ymin)} {[1, 2, 3], [0.5, 1.0, 2.0]}
A band given :xmin and :xmax runs up the panel:
iex> frame =
...> %{"y" => [1, 2], "low" => [1.0, 0.5], "high" => [3.0, 2.0]}
...> |> Giggly.Plot.new(%{y: :y, xmin: :low, xmax: :high})
...> |> Giggly.Plot.geom_ribbon(colour: "black")
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :flipped_aes)
[true, true]
@spec geom_rug(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of rugs: a short line at the panel's edge for each row, at its x along the
bottom and at its y along the left, so the margins show how each axis's values are spread,
beside a scatter plot of the same rows. Every row is drawn, so rugs suit small tables.
Rugs use :x, :y, :group, :alpha, :color, :linetype and :linewidth, and need one
of :x and :y; a side whose axis is not mapped draws nothing. sides: says which sides are
drawn, in any order. Each line runs in from the panel's edge as far as length: says, by
default 3% of the panel, which the 5% of room the axes leave at each end keeps clear of the
data; with outside: true it runs out from the edge instead, which shows only where
coord_cartesian/2 leaves the panel unclipped. A row missing its place draws no line along
that axis's sides, and an infinite one is at the panel's corner. Where the rugs run along both
axes, a row repeated in every column is drawn once on each side, as ggplot2 draws it. Each line
takes its own row's colour, alpha, width and line type; a colour of :none draws none, and so
does the line type :blank. Under coord_radial/2 the lines are straight all the same, along
the panel's square edges at each row's place, and a rug needs both :x and :y there.
With position: :jitter each row moves as geom_jitter/3 moves the points of the same rows,
so a rug beside them marks each point; it needs both :x and :y.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. Jittering needs both:xand:y. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:sides- The sides of the panel the rugs are drawn along, a list of:top,:right,:bottomand:left, each given once: anxalong the bottom and top, ayalong the left and right. The default value is[:bottom, :left].:length- How long each line is,{amount, unit}: a share of the panel (:npc), or a length in:pt,:cm,:mmor:in. The default value is{0.03, :npc}.:outside(boolean/0) - Whether each line runs out from the panel's edge rather than in, which shows only where the panel is not clipped (coord_cartesian/2'sclip: :off). The default value isfalse.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_rug(sides: [:bottom, :right], length: {2, :mm}) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)} {[2.62, 2.875], [21.0, 22.8]}
Rows repeated in every column are drawn once on each side where the rugs run along both axes, so these three rows draw two lines along the bottom and two along the left:
iex> svg =
...> %{"x" => [1.0, 1.0, 2.0], "y" => [5.0, 5.0, 6.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.geom_rug()
...> |> Giggly.Plot.theme_void()
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> ~r/<line / |> Regex.scan(svg) |> length()
4
@spec geom_segment(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of segments: a straight line for each row, from its x and y to its xend and
yend, for a line joining two points the data names apart, such as a span of time or a spike
down to an axis.
Segments use :x, :y, :xend, :yend, :group, :alpha, :color, :linetype and
:linewidth, and need :x, :y and one of :xend and :yend: a segment given only :xend
ends at its own y, and one given only :yend at its own x. A row missing a position, its
width or its line type draws no segment, and an infinite position reaches the panel's edge. Each
segment takes its own row's colour, alpha, width and line type; a colour of :none draws none,
and so does the line type :blank, though a blank segment's closed arrowhead is still filled. Under coord_radial/2 a segment follows the panel's curves,
as a path from its start to its end does.
arrow: puts an arrowhead on each segment, in its colour, width and line type, a closed one
filled with its colour or the arrow's fill: at its alpha; under coord_radial/2 a closed head
is filled with its segment's colour whatever the fill:.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). Or a list of them, one for each row of the layer's table, each row's line drawn so. The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). Or a list of them, one for each row of the layer's table, each row's line drawn so. The default value is:round.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"start" => [1.0, 2.0], "finish" => [3.0, 5.0], "row" => [1.0, 2.0]} ...> |> Giggly.Plot.new(%{x: :start, xend: :finish, y: :row}) ...> |> Giggly.Plot.geom_segment(lineend: :round) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :xend)} {[1.0, 2.0], [3.0, 5.0]}
A closed head filled white:
iex> svg =
...> %{"x" => [1.0], "y" => [1.0], "xend" => [2.0], "yend" => [3.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, xend: :xend, yend: :yend})
...> |> Giggly.Plot.geom_segment(arrow: [type: :closed, fill: "white"])
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ "fill: #FFFFFF;"
true
@spec geom_smooth(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of smooths: a curve fitted to each group's rows, for the trend through a cloud of points, drawn over its band, the confidence interval around it.
Each curve is worked out at n: evenly spaced places from the group's least x to its
greatest, or across the whole x axis with fullrange: true, and drawn over its band, its
standard error times a quantile at level: either side of it, the t distribution's for lm and
loess and the normal distribution's for gam. Each row is
weighted by its :weight where one is mapped; a row missing x or y, or at an infinite one,
or missing its weight, is left out, and a group holding fewer than two distinct x, or a weight
below 0 or infinite, is drawn nothing.
With method: :lm each curve is a straight line by least squares, y fitted to x; a row
weighted 0 is left out, a group whose weighted rows hold one x is drawn flat at their weighted
mean, and where the line meets every row, as through two, no band is drawn.
With method: :loess, each place's value is a quadratic fitted by least squares to the share
span: of the group's rows nearest it, nearer rows weighing more, so the curve follows the rows'
trend wherever it bends. It is drawn only across the group's rows, even with fullrange: true; a
row weighted 0 leaves the band out; and a group too small for its span to hold three distinct x
round each place, as one of five rows at the default span, is drawn nothing.
With method: :gam, each curve is a smoothing spline: a cubic curve through ten knots spread
evenly through the group's distinct x, its wiggliness penalised by as much as the rows bear
out, chosen by restricted maximum likelihood, and straight beyond the outermost knots, as
fullrange: true shows. A row weighted 0 still places the knots but adds nothing to the fit,
and a group of fewer than ten distinct x, or whose rows weighted above 0 share one y, is
drawn nothing.
A smooth given no method fits loess where the largest group in any panel holds under 1,000 rows, and gam from there.
Smooths use :x, :y, :weight, :group, :alpha, :fill, :color, :linetype and
:linewidth, and need :x and :y; a :weight column must hold numbers. A curve's line is
drawn in its colour's own alpha, and :alpha fills its band.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:smooth.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:method- How each curve is fitted::lm, a straight line by least squares;:loess, at each place a quadratic fitted to the nearest rows, nearer ones weighing more; or:gam, a smoothing spline, its wiggliness chosen from the rows; each row weighted too by its:weightwhere one is mapped. When not given, loess where the largest group in any panel holds under 1,000 rows, and gam from there.:se(boolean/0) - Whether each curve is drawn over its band, the confidence interval around it atlevel:. The default value istrue.:level- How confident each band is, above 0 and below 1. The default value is0.95.:n(pos_integer/0) - How many evenly spaced places along x each curve is worked out at. The default value is80.:span- How much of a group each loess fit reads, above 0: the share of its rows nearest each place, so a smaller span follows the rows more closely; only loess reads it. The default value is0.75.:fullrange(boolean/0) - Whether each curve spans the panel's axis it runs along, short of its widening, rather than its own group's extent along it. The default value isfalse.:orientation- The axis each curve runs along::x, y fitted to x, or:y, x fitted to y, for a curve that runs up the panel. The default value is:x.:alpha- How opaque every band's fill is, from 0, invisible, to 1, opaque; 0.4 when not given. The line keeps its colour's own alpha.:color- The colour of every curve's line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent,#3366FF, when not given.:fill- The colour every band is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 60% toward its paper,#999999, or#00000066undertheme_void/2, whose paper is clear.:linewidth- How wide every curve's line is, in millimetres; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 3.0, 4.0], "y" => [1.0, 3.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_smooth(method: :lm, n: 3) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)} {[1.0, 2.5, 4.0], [1.2999999999999998, 2.5, 3.7]}
Without its band, a curve carries no standard error:
iex> frame =
...> %{"x" => [1.0, 2.0, 3.0, 4.0], "y" => [1.0, 3.0, 2.0, 4.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.geom_smooth(method: :lm, se: false, n: 3)
...> |> Giggly.layer_data()
iex> :se in Giggly.DataFrame.names(frame)
false
@spec geom_spoke(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of spokes: a straight line for each row, from its x and y, running radius in
the direction angle, for data that records a direction and a distance, such as wind or
movement.
Spokes use :x, :y, :angle, :radius, :group, :alpha, :color, :linetype and
:linewidth, and need :x, :y, :angle and :radius, angle: and radius: setting one
for every spoke over any the mapping gives. An angle is in radians, anticlockwise from east, so
:math.pi() / 2 points up, and a radius is in the axes' units, the same distance along each,
so a spoke's length on the page changes with its direction where the axes are scaled apart.
Neither is mapped through a scale. Each spoke ends at x + cos(angle) * radius and y + sin(angle) * radius, worked out before the axes are trained a second time, so the spokes' ends
widen them, and on an axis whose scale transforms its positions the spoke runs in the
transformed units. A row missing a position, its angle or its radius draws no spoke. Each is
drawn as geom_segment/3 draws a segment, taking its row's colour, alpha, width and line type,
with arrow:'s arrowhead at its end.
Raises ArgumentError when the plot is run for an angle or a radius that is not a number.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:angle- The direction every spoke runs in, in radians, anticlockwise from east, over any the mapping gives.:radius- How far every spoke runs, in the axes' units, over any the mapping gives; a negative one runs the other way.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). Or a list of them, one for each row of the layer's table, each row's line drawn so. The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). Or a list of them, one for each row of the layer's table, each row's line drawn so. The default value is:round.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0], "y" => [1.0, 1.0], "direction" => [0.0, :math.pi()]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_spoke(%{angle: :direction}, radius: 0.5) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xend), Giggly.DataFrame.pull(frame, :radius)} {[1.5, 1.5], [0.5, 0.5]}
A spoke with an arrowhead points the way it runs:
iex> svg =
...> %{"x" => [1.0], "y" => [1.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.geom_spoke(angle: 1.0, radius: 2.0, arrow: true)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ "<polyline points="
true
@spec geom_step(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of steps: a line through each group's rows in order of their x that moves in
stairs, changing one position at a time, so it shows exactly where each value changes, as a
count or a rate held until its next reading is drawn; or in order of their y with
orientation: :y. Rows that share a position keep the order the data gives them. Steps are
drawn as geom_path/3 draws paths, through the stairs, and take the same aesthetics.
The layer's table keeps its rows as the data gives them: the stairs are built as each panel is drawn. A row missing a position, a colour, a width or a line type at a group's start or end, in the data's order, is dropped before its rows are put in order; one in the middle breaks its line where the stairs meet it. A group of one row draws nothing.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:orientation- Which position the rows are put in order of:x, oryfor a line that runs up the panel. The default value is:x.:direction- How the stairs run from each row to the next: across and then up (:hv), up and then across (:vh), or changing halfway between them (:mid), along y as along x. The default value is:hv.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel). The default value is:round.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"x" => [1.0, 3.0, 2.0], "y" => [2.0, 1.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_step(direction: :mid) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :x) [1.0, 3.0, 2.0] iex> Giggly.DataFrame.pull(frame, :y) [2.0, 1.0, 4.0]
@spec geom_text(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of text: each row's label at its x and y.
Text is written as it is; a whole number has no decimal point (21, not 21.0), any other
number up to 15 significant digits, in scientific notation when that is shorter (1e+05), and a
boolean is TRUE or FALSE. Each label is centred on its place, black and 11 points tall,
unless the options say otherwise. A label breaks over lines at each "\n", its lines
justified together and turned with it. A row missing its x, y or label draws nothing.
Text uses :x, :y, :label, :group, :alpha, :color, :size, :angle, :hjust,
:vjust, :family, :fontface and :lineheight, and needs :x, :y and :label; a label
never groups the rows. A mapped size goes through the size scale and is shown in a legend; a
mapped angle, justification, family, face or line height is used as the data holds it, with no
scale and in no legend's keys: numbers of degrees, numbers or the words the options take as
text ("inward"), fonts' names, a face's number from 1 to 5 (plain, bold, italic, bold italic,
symbol) or its word, "plain", "bold", "italic", "bold.italic" or "symbol", a factor's
read as its words, and numbers of lines. Raises ArgumentError when the plot is run for a
column of anything else, a factor's justification or line height among them. A row missing its
angle draws nothing, and an infinite angle or line height raises when the plot is drawn; a
missing justification, or a word not among them, centres its label; a size, family or line
height missing in some of a panel's rows and not others raises when the plot is drawn, and a
panel missing every line height spaces its lines at 1.2;
a missing number is the plain face, and a missing word, any other number or word, or a label in
the symbol face holding a character past ASCII raises when the plot is drawn. nudge_x: and nudge_y: move every label, in the
units of each axis, and a mapped :nudge_x or :nudge_y each its own way, as its position,
:nudge unless position: says otherwise, reads them, and the axes reach the labels where they
are drawn. Raises ArgumentError for a nudge beside another position, which moves no label by
it.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:nudge.:check_overlap(boolean/0) - Whether to leave out each label that would cross one drawn before it, the rows taken in order. The default value isfalse.:size_unit- The unit every label's size is read in, its own or the theme's::mm, each 2.85 points,:pt,:cm,:inor:pc, picas of 12 points. The theme's size is read in it too, 3.87, so a layer that reads sizes in another unit and gives none draws its text 3.87 of that unit tall. A legend's keys read their sizes in millimetres whatever it is. The default value is:mm.:label_with- A function handed each row's label as text, as R'sas.character()writes it, that returns a label another library lays out (Giggly.Label), drawn in the label's place, sized and turned as the row says and justified by its whole box, as R'sparse = TRUEdraws an expression:&GigTypst.math/1. A missing label is not drawn and not handed over; the legend's key is still the letter "a", as R parses none. Not withlineheight:or the:symbolface.:none, the default, draws each label as text. The default value is:none.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every label, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:size- How big every label is, in the unitsize_unit:gives, millimetres unless it says otherwise; the theme'sbase_sizewhen not given, 11 points at its default sizes.:angle- How far every label is turned, in degrees anticlockwise; 0 when not given.:hjust- Where along its baseline every label is anchored on its place, 0 its start and 1 its end: a number from 0 to 1, or one of the words:left,:centerand:right,:bottom,:middleand:top, or:inwardand:outward, which justify each label toward or away from the middle of the panel by where it falls; 0.5 when not given.:vjust- Where up its height every label is anchored on its place, 0 its baseline and 1 the top of a capital letter: a number from 0 to 1, or one of the words:left,:centerand:right,:bottom,:middleand:top, or:inwardand:outward, which justify each label toward or away from the middle of the panel by where it falls; 0.5 when not given.:family(String.t/0) - The font every label is drawn in, by name, such as"Times New Roman", or one of the generic families"sans","serif"and"mono"; the theme'sbase_familywhen not given, the default sans-serif at its default. How a label is measured and drawn in it: the fonts guide.:fontface- The face every label is drawn in::plain,:bold,:italic,:bold_italic, or:symbol, R's symbol font, which writes each letter of a label as a Greek one ("Mg"as"Μγ") and some signs as others (@as≅), and takes only ASCII characters;:plainwhen not given.:lineheight- How far apart the lines of every label are, which breaks at each"\n": any number, each line1.2 * lineheighttimes the label's size below the one before, 0 setting every line on one baseline and a negative one stacking them upward; 1.2 when not given. A legend's keys space their lines 1.2 apart whatever it is.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> plot = ...> %{"wt" => [2.62, 2.32], "mpg" => [21.0, 22.8], "model" => ["Mazda RX4", "Datsun 710"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, label: :model}) ...> |> Giggly.Plot.geom_text(hjust: :inward, size: 5) iex> frame = Giggly.layer_data(plot) iex> Giggly.DataFrame.pull(frame, :label) ["Mazda RX4", "Datsun 710"] iex> Giggly.DataFrame.pull(frame, :hjust) [:inward, :inward]
A whole number is labelled without a decimal point, and a large one in scientific notation:
iex> svg =
...> %{"x" => [1.0, 2.0], "y" => [1.0, 2.0], "count" => [21.0, 100_000.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, label: :count})
...> |> Giggly.Plot.geom_text()
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ ">21</text>", svg =~ ">1e+05</text>"}
{true, true}Nudged labels sit off the points they name:
iex> frame =
...> %{"x" => [1.0, 2.0, 3.0], "y" => [1.0, 4.0, 2.0], "name" => ["a", "b", "c"]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, label: :name})
...> |> Giggly.Plot.geom_text(nudge_x: 0.1, nudge_y: -0.2)
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)}
{[1.1, 2.1, 3.1], [0.8, 3.8, 1.8]}
@spec geom_tile(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of tiles, one per row, each a rectangle centred on its x and y, for a surface
or a grid of values drawn as colours.
Each tile is as wide as the closest spacing of the x positions in its panel and as tall as
that of the y positions, 1 on a discrete axis, and on a continuous one the closest gap, a
column of integers spaced as any numbers are; or as wide as its mapped :width and as tall as its
mapped :height, numbers, or as width: and height: make every tile, which win over mapped
ones. A row missing its x or y draws nothing.
Tiles use :x, :y, :group, :alpha, :fill, :color, :linetype, :linewidth,
:width and :height, and need :x and :y. :fill fills a tile and takes its alpha;
:color borders it, and tiles have no border unless it is mapped or set; :linewidth and
:linetype say how wide the border is and how it is dashed.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every tile's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every tile is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every tile's border is, in millimetres; 0.4 times the theme'sbase_line_sizewhen not given, 0.2 at its default sizes.:linetype- The line type of every tile's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:width- How wide every tile is, in the units of the x axis, any number; it replaces the width the tiles would take otherwise, and a mapped:width.:height- How tall every tile is, in the units of the y axis, aswidth:sets a width.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [2.0, 5.0, 7.0, 9.0, 12.0], "y" => [1.0, 1.0, 1.0, 1.0, 1.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_tile() ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)} {[1.0, 4.0, 6.0, 8.0, 11.0], [3.0, 6.0, 8.0, 10.0, 13.0]}
Mapped widths make tiles of different sizes, here meeting edge to edge:
iex> frame =
...> %{"x" => [2.0, 5.0, 7.0, 9.0, 12.0], "y" => [1.0, 1.0, 1.0, 1.0, 1.0],
...> "w" => [4.0, 2.0, 2.0, 2.0, 4.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, width: :w})
...> |> Giggly.Plot.geom_tile()
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :xmin), Giggly.DataFrame.pull(frame, :xmax)}
{[0.0, 4.0, 6.0, 8.0, 10.0], [4.0, 6.0, 8.0, 10.0, 14.0]}
@spec geom_violin(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of violins: for each group, a density of its y mirrored about its x, a compact
view of its distribution, drawn where a box plot would draw its box.
Each violin's outline is a kernel density estimate of its group's y, worked out as
geom_density/3 works one out, its bandwidth from every row of the group: a kernel, a normal
curve unless kernel: says otherwise, put at each row and summed, its spread bw: times
adjust:, each row weighing as its :weight where one is mapped. A violin spans its own group's
extent, at 512 evenly spaced places, unless trim: false lets its tails reach three bandwidths
past it, and bounds: folds back what lies beyond a finite bound. Each violin is as wide at a
place as its density there makes it beside the panel's greatest, so every violin has the same
area, unless scale: says otherwise; it stands at its group's x, or the middle of its group's
x values where they are several, in a room 0.9 times the closest spacing of the x positions
wide, counting from zero, or 0.9 of the range of those values, or as wide as its group's mapped
:width, or as width: says. A row missing its x, y or weight, or at an infinite one, is
left out; a group of fewer than two rows is left out too, unless drop: false keeps it as room
for a position. A panel where some group's weight is below 0 is drawn nothing.
Violins stand along the discrete one of x and y, so mapping a discrete y beside a numeric
x draws horizontal violins; where both are continuous they stand along the axis on which every
group holds one value, or else along x, each group a violin. orientation: says which.
Violins sharing a position are set side by side, as position: says.
Violins use :x, :y, :group, :weight, :width, :alpha, :color, :fill,
:linetype and :linewidth, and need :x and :y. A look reaches a violin from its group's
first row, so a discrete one groups the rows and gives each group its own violin. Each is
bordered in the theme's ink mixed 20% toward its paper and filled with its paper unless a look
is mapped or set.
Given another stat in stat:, a layer maps each row's :violinwidth, needed, how far the
violin reaches toward its room's side there, from 0 at its x to 1, and the violins stand up
unless orientation: :y lays them across.
Given a quantile_linetype:, each violin is drawn with a line across it at each of the
quantiles of its group's y its densities mark (quantiles:, its quartiles unless given), side
to side at the violin's width there, from its lowest to its highest; each line in its quantile's
row's colour, at its alpha, and width unless quantile_color: and quantile_linewidth: give
them. Every border and line is drawn with butt ends and round corners; lineend: and
linejoin: draw the legend's keys.
Each group's densities compute each place's density; scaled, the density over the group's
greatest; count, the density times its rows; violinwidth, how wide the violin is there;
n, its rows; width, its room's width where the stat gives one; and quantile, which the
rows marking quantiles: hold, which a mapping reads with an after_stat (Giggly.Mapping).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:ydensity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:dodge.:bw- How smooth each curve is, its bandwidth, the kernel's standard deviation in the axis's transformed units: a number above 0, or a rule worked out from each group's rows, taking no weight: Silverman's rule of thumb (:nrd0), 0.9 times the lesser of the rows' standard deviation and their interquartile range over 1.34, times the rows to the power -0.2, or Scott's variation of it (:nrd), 1.06 times the lesser. The default value is:nrd0.:adjust- A multiple of the bandwidth, above 0:adjust: 0.5halves it, for a curve that follows the rows more closely, andadjust: 2doubles it, for a smoother one. The default value is1.0.:kernel- The shape put at each row and summed, scaled so its standard deviation is the bandwidth: a normal curve (:gaussian), a parabola (:epanechnikov), a block (:rectangular), a tent (:triangular), a parabola squared (:biweight), or a cosine's hump (:cosine) or a narrower one (:optcosine). The default value is:gaussian.:trim(boolean/0) - Whether each violin spans only its own group's extent;falsereaches three of the rule's bandwidths, beforeadjust:, past it either end, so its tails show. The default value istrue.:bounds- Limits the rows are known to lie within,{low, high}, the low a number or:neg_infinity, the high a number or:infinity, not below the low: the rows outside them are left out, and each curve's part beyond a finite one is folded back inside it, so the curve does not spill past a limit the data cannot. The default value is{:neg_infinity, :infinity}.:scale- How the violins are sized beside one another: each the same area (:area), as wide as its density makes it beside the panel's greatest; that times its rows over the panel's most, so a violin of more rows is bigger (:count); or each as wide at its widest (:width). The default value is:area.:quantiles- The quantiles of each group'sythe densities mark, each a row of its own whosequantileis its probability, a list of numbers from 0 to 1, or:nonefor noquantilecolumn at all. The default value is[0.25, 0.5, 0.75].:drop(boolean/0) - Whether to leave out a group of fewer than two rows, or,false, keep it as one row of missing densities, so a position makes room for it. The default value istrue.:width- How wide a violin's room is, in the units of the axis it stands on, any number; it replaces a mapped:width, and gives way to 0.9 of the range of a group spanning several positions. 0.9 times the closest spacing of the positions, counting from zero, when not given.:orientation- The axis the violins stand along,:xor:y, estimating the other; when not given they stand along the discrete one, or else along the axis on which every group holds one value, or else along x.:alpha- How opaque every violin's fill and quantile lines are, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every violin's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2.:fill- The colour every violin is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's paper when not given, white, or clear undertheme_void/2.:linewidth- How wide every violin's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every violin's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:quantile_color- The colour of the lines across each violin at the quantiles its densities mark, writtenquantile_colour:orquantile_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; its violin's border colour when not given.:quantile_linetype- The line type of the lines across each violin at the quantiles its densities mark (quantiles:)::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:blank, drawing none, when not given. The default value is:blank.:quantile_linewidth- How wide the quantile lines are, in millimetres; their violin's border width when not given.:lineend- How the borders of the legend's keys end: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square); the violins' own borders are always cut square at the end. The default value is:butt.:linejoin- How the borders of the legend's keys turn a corner: pointed (:mitre), rounded (:round) or cut off (:bevel); when not given the glyph's own: pointed for a rectangle's, rounded for a time series'; the violins' own borders always turn rounded.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"g" => ["a", "a", "a"], "y" => [1.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :g, y: :y}) ...> |> Giggly.Plot.geom_violin(quantiles: [0.5]) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.row_count(frame), Enum.at(Giggly.DataFrame.pull(frame, :y), -1)} {513, 2.0}
@spec geom_vline(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of vertical reference lines: a line up the whole panel at each xintercept, for
a date to mark, a threshold or a mean drawn over the data.
The lines are given in one of two ways. xintercept: gives them as values, a line for each,
drawn in every panel and in no legend. Or the layer maps :xintercept from a table, its own
data: or the plot's, so the lines can differ from panel to panel under a facet and map a
colour, alpha, width or line type into a legend. Either way the layer takes nothing from the
plot's mapping, and titles no axis.
Vertical lines use :xintercept, :group, :alpha, :color, :linetype and :linewidth,
and need :xintercept, which the x axis widens to show and puts through its scale as it does
x: a number on a continuous axis, a string on a discrete one, a date, a date-time or a time
on such an axis, and :infinity or :neg_infinity at the panel's edge. A line repeated in a
panel is drawn once. Beside xintercept:, each look option takes one value or a list, one per
line, every list as long as the others. A line missing its xintercept, as a scale's limits
leave it, draws nothing, and so do a colour of :none and the line type :blank. Under
coord_radial/2 each line is a spoke from the centre, or a circle under theta: :y.
Raises ArgumentError for xintercept: beside a mapping or data:, for a list of looks
without xintercept:, and for lists of different lengths.
Options
:data(term/0) - A table for the layer's mapping to draw from instead of the plot's data, anything implementingTable.Reader; refused beside the options giving lines as values, which draw lines of their own. Under a facet, a table lacking a faceting column is drawn in every panel.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added. Taken only beside a mapping.:position- Where the lines are moved: left where they cross the axis (:identity), or nudged (:nudge), as Positions says. The default value is:identity.:xintercept- Where each line crosses the x axis, in its units: a value, or a list of them, a line for each, drawn in every panel. Given, the layer takes no mapping and nodata:.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:alpha- How opaque each line is, from 0, invisible, to 1, opaque.:color- The colour of each line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide each line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of each line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.iex> frame = ...> %{"wt" => [2.62, 3.44], "mpg" => [21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.geom_vline(xintercept: [3, 5], linetype: :dashed) ...> |> Giggly.layer_data(1) iex> Giggly.DataFrame.pull(frame, :xintercept) [3.0, 5.0]
Sets the guide that reads each aesthetic's scale back: for an axis, :axis, ticks and labels
beside the panel, or {:axis, options}, one drawn as its options say, or :axis_logticks or
{:axis_logticks, options}, one with logarithmic ticks, or :axis_stack or {:axis_stack, options}, several one beyond the other, or for the angle round a radial panel's circle
:axis_theta or {:axis_theta, options}; for any other
aesthetic, :legend, a key for each break; :colorbar, a bar a continuous colour or fill
scale's colours run up; :colorsteps, a bar of one block of colour for each bin between a
colour or fill scale's breaks, all as long whatever the bins' widths, each break's label at its
edge; or {:legend, options}, a legend drawn as its options say; or :none for none, which
keeps an axis's title. The options are in "Guides" above.
A guide set here wins over the one its scale's guide: chooses, before or after the scale is
given. Each call sets only the guides it is given, keeping the rest. A legend, a colour bar or
colour steps for an axis raise here, and so do a colour bar or colour steps for alpha, shape or
size; either for a colour or fill scale that is discrete, or a colour bar for a binned one,
raises when the plot is run. Under coord_radial/2 the axes are theta:, the angle, and r:,
the radius, and x: and y: read nothing; elsewhere theta: and r: do. A guide for an
aesthetic no layer maps reads nothing.
A custom guide, {:custom, options}, draws SVG markup of your own beside the legends, belonging
to no scale, under a name of its own that no aesthetic or axis has, such as logo:; several
stand in the order of their names, after the scales' legends among those of their order:. Its
svg: is written into the drawing as it is, never read or checked, in a space width: by
height:, which it needs, since nothing reads the markup's own size.
Options
:x- The x axis's guide, asscale_x_continuous/2'sguide:takes it; undercoord_radial/2, whose x is the angle or the radius, it reads nothing.:y- The y axis's guide, asscale_y_continuous/2'sguide:takes it; undercoord_radial/2, whose y is the radius or the angle, it reads nothing.:x_sec- A copy of the x axis on the side of the panels opposite it, its breaks and labels and no title,:nonefor none, asx:takes a guide; none when not given. Where the x scale has a secondary axis (sec_axis:), the guide that draws it, over the secondary axis's own. Undercoord_radial/2it reads nothing.:y_sec- A copy of the y axis on the side of the panels opposite it, asx_sec:copies the x axis.:r- The radius axis's guide undercoord_radial/2, asscale_y_continuous/2'sguide:takes it, over the radius's scale's own; elsewhere it reads nothing.:theta- The angle axis's guide undercoord_radial/2::axis_thetaor{:axis_theta, options}, the axis round the circle,{:axis_stack, options}of them, rings one beyond the other, or:nonefor none; elsewhere it reads nothing.:color- The colour scale's guide (colour:too), asscale_color_continuous/2'sguide:takes it; a colour bar for a continuous scale alone, colour steps and a binned legend for a binned or continuous one.:fill- The fill scale's guide, asscale_fill_continuous/2'sguide:takes it; a colour bar for a continuous scale alone, colour steps and a binned legend for a binned or continuous one.:alpha- The alpha scale's guide, asscale_alpha_continuous/2'sguide:takes it; a binned legend for a binned or continuous scale alone.:shape- The shape scale's guide, asscale_shape_discrete/2'sguide:takes it; a binned legend for a binned scale alone.:size- The size scale's guide, asscale_size_continuous/2'sguide:takes it; a binned legend for a binned or continuous scale alone.:linetype- The line type scale's guide, asscale_linetype_discrete/2'sguide:takes it; a binned legend for a binned scale alone.:linewidth- The line width scale's guide, asscale_linewidth_continuous/2'sguide:takes it; a binned legend for a binned or continuous scale alone.
Custom guides
:svg(String.t/0) - Required. What the guide draws: SVG markup, written into the drawing as it is and never read or checked. Its coordinates are points from the top left of the spacewidth:andheight:give it, and a root<svg>with only aviewBoxis scaled to fill that space; it may draw past its edges.:width- Required. How wide the drawing's space is,{amount, unit}with a unit of [:pt, :cm, :mm, :in, :lines], 0 or more.:height- Required. How tall the drawing's space is,{amount, unit}with a unit of [:pt, :cm, :mm, :in, :lines], 0 or more.:title- The guide's title, a string, a label (Giggly.Label), or:nonefor none, as when not given.:order- Where the guide stands among the plot's legends, 1 first, a whole number to 99; guides not given one after those given one, as if 99, a scale's legends before custom guides, which stand in the order given.:position- Where the guide goes,:right,:left,:topor:bottomof the panels or:insidethem, over the theme'slegend_position; guides going to one place stack in one box, and an inside guide goes at its own theme'slegend_position_insideandlegend_justification_inside, else the plot's, a box for each point. The theme'slegend_position: :nonedraws no guide, this one included.:theme- The guide's own theme, any oftheme/2's settings, checked as it checks them, or a theme of settings alone thattheme/2returned, but not a complete theme, laid over the plot's theme for this guide alone, so[legend_text: [size: 14]]keeps the plot's label colour, and an element the plot removed is drawn as given. Itslegend_directionruns the keys wheredirection:does not say; an element the guide does not draw, such aslegend_positionor the box's, changes nothing. A key length it gives a colour bar or colour steps,legend_key_heightrunning up andlegend_key_widthacross, is the whole bar's, where the plot's is a key's, five making the bar. Guides that merge keep each one's elements, and an element both give different values raises when the plot is run.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.guides( ...> logo: {:custom, svg: ~s(<rect width="20" height="10"/>), width: {1, :cm}, height: {0.5, :cm}} ...> ) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> svg =~ ~s(<rect width="20" height="10"/>) true
iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8], "cyl" => ["6", "4"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.guides(color: :none) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> svg =~ ">cyl</text>" false
Sets the plot's labels: the title of an axis or a legend, named by its aesthetic, the plot's
title, subtitle, caption and tag, and its alternative text, which Giggly.get_alt_text/1 reads.
An axis or legend is otherwise titled by what is mapped to it (Giggly.Mapping); a label set
here replaces that title, whether the layer was added before or after. A label of :none
removes the title and the room it took, and "" keeps the room and draws nothing. A label for an
aesthetic no layer maps titles nothing. Each call sets only the labels it is given, keeping the
rest. A label breaking over several lines ("Fuel\neconomy") is drawn a line at a time. In
place of a string, any title here, as a scale's name: and a guide's title:, may be a label
another library lays out, such as maths, a struct implementing Giggly.Label.
A dictionary: relabels by what is mapped rather than by aesthetic: a title an axis or a legend
takes from what is mapped to it, a column's name such as "mpg", an expression's text such as
"factor(cyl)" or a stat's column such as "count", becomes its entry, wherever it is drawn;
a title without one is kept, and so is a label set here by aesthetic, which wins. A second
dictionary: replaces the first.
The title and subtitle are drawn above the panels, from their left edge; the caption below them,
to their right edge; and the tag at the plot's top left. theme/2's plot_title_position: :plot
and plot_caption_position: :plot line them up with the whole plot inside its margin instead,
the axes' titles and any legends beside the panels included, and its plot_tag_position: and
plot_tag_location: put the tag at another corner or side, or at a point, in the margin, over
the plot or over the panels.
Options
:x- The x axis's title.:y- The y axis's title.:color- The colour legend's or colour bar's title (colour:too).:fill- The fill legend's or colour bar's title.:alpha- The alpha legend's title.:shape- The shape legend's title.:size- The size legend's title.:linetype- The line type legend's title.:linewidth- The line width legend's title.:title- The plot's title, above the panels.:subtitle- The plot's subtitle, below its title.:caption- The plot's caption, below the panels.:tag- The plot's tag, at its top left unless the theme puts it elsewhere.:dictionary(map ofString.t/0keys andString.t/0values) - A map from a title an axis or a legend is given by what is mapped to it, such as a column's name, to the title it takes in its place.:alt- The plot's alternative text, for a page to give in place of its drawing, whichGiggly.get_alt_text/1returns: a string,:nonefor none, or a function of one argument, handed the plot, returning one.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.labs(x: "Weight (1000 lbs)", y: :none, title: "Fuel economy") ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">Weight (1000 lbs)</text>", svg =~ ">mpg</text>", svg =~ ">Fuel economy</text>"} {true, false, true}
iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.labs(dictionary: %{"mpg" => "Miles per gallon"}) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">Miles per gallon</text>", svg =~ ">wt</text>"} {true, true}
@spec layer(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of any stat and any geom, ggplot2's layer(): stat: and geom: each name one of
Giggly's by its function's name, as the layer functions' stat: and geom: do, or give a
module, a plugin's, adopting Giggly.Stat or Giggly.Geom.
The call takes the options the stat and the geom take, as a geom function given that stat
does, and is checked against both as Giggly's own layer functions check theirs. A plugin's own
layer function calls it with its stat and geom and its default position:; function:, the
name of that function as it would be written in a message ("MyPlugin.geom_ridgeline/3"),
makes each refusal name it, Plot.layer/3 where none is given.
A geom given as a module takes every option that sets an aesthetic for every mark that Giggly
checks, colour:, fill:, alpha: and the rest, each checked as Giggly's layer functions
check it, and refuses those its accepted_aesthetics/1 does not name; its marks take the
positions points take.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:point, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:point.:stat- The stat that computes the layer's table before it is drawn: one of Giggly's by the name of itsstat_function,:countcounting,:bin_2dbinning in rectangles, or a module stating the stat facts and computing as a stat. Given another stat than its own, the layer takes that stat's options, as its function documents them, in place of its own stat's. The default value is:identity.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
stat: is :identity and geom: :point unless given, so a layer given neither draws a
table's rows as points. Its position: is :identity unless given.
iex> frame =
...> %{"x" => [1.0, 2.0, 2.0, 3.0]}
...> |> Giggly.Plot.new(%{x: :x})
...> |> Giggly.Plot.layer(stat: :count, geom: :point, function: "MyPlugin.geom_tally/3")
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :y)
[1.0, 2.0, 1.0]
Gives the plot a scale with the given limits for each axis named, replacing any scale it had for
it, as xlim/3, xlim/2, ylim/3 and ylim/2 do: {low, high} for a continuous or a date
scale, a list of values for a discrete one.
Options
:color- The colour scale's limits (colour:too):{low, high}for a continuous scale, asscale_color_continuous/2takes them, two numbers high to low running it from high to low, astransform: :reverseruns it, two dates or two date-times for a date or a date-time one, asscale_color_date/2andscale_color_datetime/2take them, or a list of values for a discrete one, asscale_color_discrete/2does.:fill- The fill scale's limits, asscale_fill_continuous/2orscale_fill_discrete/2takes them.:alpha- The alpha scale's limits, asscale_alpha_continuous/2orscale_alpha_discrete/2takes them.:shape- The shape scale's limits, a list of values, asscale_shape_discrete/2takes them.:size- The size scale's limits, asscale_size_continuous/2orscale_size_discrete/2takes them.:linetype- The line type scale's limits, a list of values, asscale_linetype_discrete/2takes them.:linewidth- The line width scale's limits, asscale_linewidth_continuous/2orscale_linewidth_discrete/2takes them.iex> plot = ...> %{"wt" => [1.5, 2.6, 3.4], "mpg" => [30.4, 21.0, 18.7]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.lims(x: {2, 4}, y: {15, 25}) iex> frame = Giggly.layer_data(plot) iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)} {[nil, 2.6, 3.4], [nil, 21.0, 18.7]}
@spec new(Table.Reader.t() | :none, mapping_argument()) :: t()
A plot of data, with mapping applying to every layer.
The mapping's columns are checked by the layers that use them when the plot is run, so a
misspelt column is reported then, naming the first layer to take it. Raises ArgumentError for
a value that is not a column, an expression or a constant (Giggly.Mapping).
data is :none when not given: a plot with no data, whose layers each bring their own table
with data:, or map only constants, drawing one mark each, or draw a function
(geom_function/3); a layer mapping a column of no table of its own is refused.
new(:none, mapping) gives such a plot a mapping its layers' own tables are read by.
iex> plot =
...> Giggly.Plot.new(
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8], "cyl" => ["6", "4"]},
...> %{x: :wt, y: "mpg", colour: :cyl}
...> )
iex> plot.mapping
%{x: "wt", y: "mpg", color: "cyl"}
@spec put_data(t(), Table.Reader.t()) :: t()
The plot with data as its data, in place of any it had, so every layer drawing the plot's data
draws data; a layer with a table of its own keeps it.
data is checked against the plot's mapping and its layers when the plot is run, so it may come
after the layers that draw it.
iex> plot =
...> %{"wt" => [2.62, 2.875, 3.215], "mpg" => [21.0, 22.8, 21.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
iex> plot
...> |> Giggly.Plot.put_data(%{"wt" => [3.44], "mpg" => [18.7]})
...> |> Giggly.layer_data()
...> |> Giggly.DataFrame.pull(:y)
[18.7]
Gives the plot a binned alpha scale, replacing any alpha scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin is drawn at one opacity, as far from the first of range: to the second as the bin's
middle is through the limits. Values outside the limits take the opacity of the nearer end bin,
unless oob: says otherwise. Its guide is a binned legend, a key for each bin, unless guide:
says otherwise. Raises NimbleOptions.ValidationError for an option it does not take or a value
it cannot use, an opacity outside 0 to 1 or a guide: of :colorbar or :colorsteps, and
ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:range-{low, high}: the opacities the values run between, each from 0 to 1; the theme'spalette_alpha_continuous:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside is binned at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether a binned legend labels its ends with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.175, 0.475, 0.925]
Gives the plot a continuous alpha scale, replacing any alpha scale it had.
Each value is drawn as opaque as it is far from the first of range: to the second through the
limits; its guide is a legend unless guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, an
opacity outside 0 to 1 or a guide: of :colorbar or :colorsteps, and ArgumentError for a
list of labels without a list of breaks as long; a column that is not numbers is refused when the
plot is run.
Options
:range-{low, high}: the opacities the values run between, each from 0 to 1; the theme'spalette_alpha_continuous:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [1, 2, 3]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_continuous(range: {0, 1}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.0, 0.5, 1.0]
Gives the plot a date alpha scale, each date as opaque as it is far through the limits on
range:, replacing any alpha scale it had.
Its legend keys dates on calendar boundaries, as scale_color_date/2's colour bar marks them.
Raises ArgumentError for an option given beside its date_ twin, or a list of labels
without a list of breaks as long; a column that is not dates is refused when the plot is run.
Options
:range-{low, high}: the opacities the values run between, each from 0 to 1; the theme'spalette_alpha_continuous:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the dates the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The dates the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date, label}pairs, handed the limits,{low, high}, as dates, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[month: 3]: one of:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (Apr,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %Y". Not withlabels:.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "day" => [~D[2024-01-15], ~D[2024-05-01], ~D[2024-11-20]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, alpha: :day}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_date(range: {0.2, 1}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.2, 0.4761290322580645, 1.0]
Gives the plot a date-time alpha scale, each date-time as opaque as it is far through the
limits on range:, replacing any alpha scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Options
:range-{low, high}: the opacities the values run between, each from 0 to 1; the theme'spalette_alpha_continuous:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the date-times the scale spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The date-times the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date_time, label}pairs, handed the limits,{low, high}, as the column holds date-times, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of date-times as the column holds them, that returns a label for each, a string, a power ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:timezone(String.t/0) - The time zone the scale lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 09:00:00Z], ~U[2024-03-10 18:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, alpha: :at}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_datetime(range: {0.2, 1}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.2, 0.6000000000000001, 1.0]
Gives the plot a discrete alpha scale, replacing any alpha scale it had.
The values' opacities are spaced evenly from the first of range: to the second, in order; its
guide is a legend unless guide: says otherwise. Raises NimbleOptions.ValidationError for an
option it does not take or a value it cannot use, an opacity outside 0 to 1 or a guide: of
:colorbar or :colorsteps, and ArgumentError for a list of labels not one for each break or
limit given; a column of numbers is refused when the plot is run.
Options
:range-{first, last}: the opacities of the first and last values, each from 0 to 1; the theme'spalette_alpha_discrete:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_discrete(range: {0.25, 0.75}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.5, 0.25, 0.75]
Gives the plot an identity alpha scale, replacing any alpha scale it had: each value is drawn as
the opacity it is, unscaled; it draws no legend unless guide: asks for one.
Each value must be one alpha: takes, from 0 to 1; a missing one stays missing.
Given guide: :legend, its legend keys breaks chosen over the data's range, or over limits:, or those breaks: gives, each
drawn as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels without a list of
breaks as long; a value it cannot use, or beside a legend a column that is not numbers, is
refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:limits-{low, high}: the values the legend spans whatever the data,nilfor an end the data decides; either order names the same scale. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "a" => [0.2, 1, nil]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :a}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.2, 1.0, nil]
Gives the plot a discrete alpha scale of the opacities given, replacing any alpha scale it had.
values: gives the opacities, each from 0 to 1: a list handed to the values in order, or a map
from a value to its opacity. The legend shows a key for each value the scale shows, labelled.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
an opacity outside 0 to 1 or a guide: of :colorbar or :colorsteps among them, and
ArgumentError for a list of labels not one for each break or limit given; a column of
numbers, or more values than a list has opacities, is refused when the plot is run.
Options
:values- Required. The opacities, each from 0 to 1: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its opacity, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no opacity takesna_value:.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_manual(values: [0.2, 0.5, 1]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.5, 0.2, 1.0]
Gives the plot an alpha scale for ordered values, replacing any alpha scale it had: the scale
scale_alpha_discrete/2 gives, with its options.
The values' opacities are spaced evenly from the first of range: to the second, in their
order, so the first is the faintest; its guide is a legend unless guide: says otherwise. An
ordered factor mapped to alpha gets this scale by default. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, an
opacity outside 0 to 1 or a guide: of :colorbar or :colorsteps, and ArgumentError for a
list of labels not one for each break or limit given; a column of numbers is refused when the
plot is run.
Options
:range-{first, last}: the opacities of the first and last values, each from 0 to 1; the theme'spalette_alpha_discrete:, or else 0.1 to 1, when not given.:na_value- The opacity of a missing value, or of one outside the limits, from 0 to 1; its colour's own when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => [6, 4, 8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: {:factor, [:cyl], ordered: true}}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_alpha_ordinal(range: {0.2, 0.6}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:alpha) [0.4, 0.2, 0.6]
Gives the plot a binned colour scale, replacing any colour scale it had: the values are cut into
bins at its breaks and every value in a bin takes one colour, by default the colour at the
bin's middle of the theme's palette_color_continuous: (theme/2), or else of a gradient from
#132B43 to #56B1F7, or a colour each of palette:, a palette's name or a list, given to the
bins in order.
Values outside the limits take the colour of the nearer end bin, unless oob: says otherwise;
with neither limits nor
breaks given, the limits are the data's range widened so the end bins are as wide as their
neighbours. Its guide is colour steps, a bar of one block of colour for each bin, unless
guide: names another.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Blues"or"viridis", its colours for as many bins as there are given to them in order, or a list of colours, given to the bins in order, at least one for each; the theme'spalette_color_continuous:, or else a gradient from#132B43to#56B1F7, each bin the colour at its middle, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#265075", "#193753", "#4FA2E3"]
Gives the plot a discrete colour scale from a ColorBrewer palette, replacing any colour scale it had.
The palette is palette:, by name or by its number among the palettes of type:, its colours
given to the values in order, or in reverse for direction: -1; each palette has a set of
colours for each count from 3 to its largest, chosen to be told apart, sequential palettes for
ordered values, diverging for values either side of a middle and qualitative for values with no
order. A missing value takes no colour unless na_value: gives one. Raises
NimbleOptions.ValidationError for an option it does not take, a name ColorBrewer does not
spell so or a number below 1, and ArgumentError for a number past the last of its type's or a
list of labels not one for each break or limit given; a column of numbers, or more values than
the palette's largest set has colours, is refused when the plot is run.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- 1 to give the palette's colours to the values in order, -1 in reverse. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_brewer(palette: "Set1") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#377EB8", "#E41A1C", "#4DAF4A"]
Gives the plot a continuous colour scale, replacing any colour scale it had: the theme's
palette_color_continuous: (theme/2), or else a gradient from #132B43 to #56B1F7, as a
column of numbers gets by default, or through the colours of palette:, a palette's name or a
list, spaced evenly over the limits.
Raises NimbleOptions.ValidationError for an option it does not take, a palette's name scales
does not know, a colour CSS does not define or one with an alpha of its own, and ArgumentError
for a list of labels without a list of breaks as long; a column that is not numbers is refused
when the plot is run.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Blues"or"viridis", its colours blended in order, or a list of colours, spaced evenly from the low end of the limits to the high; the theme'spalette_color_continuous:, or else a gradient from#132B43to#56B1F7, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [5, 12, 0]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_continuous(limits: {0, 10}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#336A98", "#7F7F7F", "#132B43"]
Gives the plot a date colour scale, a gradient from low: to high:, replacing any colour
scale it had.
Each date takes the colour as far along the gradient as it is through the limits, blended in
CIE Lab*, and its guide is a colour bar unless guide: names another. The guide marks dates
on calendar boundaries, every day, week, month or year as suits the limits, or every step of
date_breaks:, each written as suits the breaks over the limits or in the format
date_labels: gives. Raises NimbleOptions.ValidationError for an option it does not take, or
a colour CSS does not define or one with an alpha of its own, and ArgumentError for an option
given beside its date_ twin, or a list of labels without a list of breaks as long; a column
that is not dates is refused when the plot is run.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the dates the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The dates the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date, label}pairs, handed the limits,{low, high}, as dates, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[month: 3]: one of:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (Apr,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %Y". Not withlabels:.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> svg = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "day" => [~D[2024-01-15], ~D[2024-05-01], ~D[2024-11-20]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, colour: :day}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_date(date_breaks: [month: 3], date_labels: "%b %Y") ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">Apr 2024</text>", svg =~ ">Oct 2024</text>"} {true, true}
Gives the plot a date-time colour scale, a gradient from low: to high:, replacing any
colour scale it had.
Each date-time takes the colour as far along the gradient as it is through the limits, as
scale_color_date/2's dates do, its guide marking date-times on clock and calendar boundaries in
its time zone, or every step of date_breaks:, each written as suits the breaks over the limits
or in the format date_labels: gives. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the date-times the scale spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The date-times the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date_time, label}pairs, handed the limits,{low, high}, as the column holds date-times, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of date-times as the column holds them, that returns a label for each, a string, a power ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:timezone(String.t/0) - The time zone the scale lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> svg = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 09:00:00Z], ~U[2024-03-10 18:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, colour: :at}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_datetime(date_labels: "%H:%M") ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">06:00</text>", svg =~ ">12:00</text>"} {true, true}
Gives the plot a discrete colour scale, replacing any colour scale it had: the theme's
palette_color_discrete: (theme/2), or else hues spaced evenly round the colour wheel, as a
discrete column gets by default, or the colours of palette:, a palette's name or a list, in
order.
Raises NimbleOptions.ValidationError for an option it does not take, a palette's name scales
does not know or a colour CSS does not define, and ArgumentError for a list of labels not one
for each break or limit given; a column of numbers, or more values than a list or a ColorBrewer
palette has colours, is refused when the plot is run.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Set1"or"viridis", or a list of colours, its colours given to the values in order; the theme'spalette_color_discrete:, or else hues spaced evenly round the colour wheel, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_discrete(palette: ["steelblue", "orange", "red"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FFA500", "#4682B4", "#FF0000"]
Gives the plot a continuous colour scale, a gradient through a ColorBrewer palette, replacing any colour scale it had.
The gradient runs through seven colours of the palette palette:, by name or by its number
among the palettes of type:, spaced evenly over the limits unless values: places them, from
its last at the low end to its first at the high, or the other way for direction: 1, blended
in CIE Lab* between neighbours, as scale_color_gradientn/2 blends its colours; its guide is a
colour bar unless guide: names another. A qualitative palette is taken too, though its colours
have no order to blend along. Raises NimbleOptions.ValidationError for an option it does not
take, a name ColorBrewer does not spell so or a number below 1, and ArgumentError for a number
past the last of its type's or a list of labels without a list of breaks as long; a column that
is not numbers is refused when the plot is run.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- -1 to blend the palette's colours from its last at the low end of the limits to its first at the high, 1 the other way. The default value is-1.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_distiller() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#084594", "#6BAED6", "#EFF3FF"]
Gives the plot a binned colour scale from a ColorBrewer palette, replacing any colour scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and the bins
take the colours of the palette palette:'s set for as many, by name or by its number among
the palettes of type:, from its last at the lowest bin to its first at the highest, or the
other way for direction: 1. Raises NimbleOptions.ValidationError for an option it does not
take, a name ColorBrewer does not spell so or a number below 1, and ArgumentError for a
number past the last of its type's, a list of labels without a list of breaks as long,
show_limits: true beside a list of labels, or n_breaks: 1 for nice breaks; a column that is
not numbers, or more bins than the palette's largest set has colours, is refused when the plot
is run.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- -1 to give the palette's colours to the bins from its last at the lowest to its first at the highest, 1 the other way. The default value is-1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_fermenter() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#3182BD", "#08519C", "#EFF3FF"]
Gives the plot a continuous colour scale diverging from mid: at midpoint:, toward low:
below it and high: above, replacing any colour scale it had.
A value's colour is as far toward its side's end as the value is from the midpoint, the end of
the limits further from the midpoint taking its colour in full and the nearer only as far as it
reaches; its guide is a colour bar unless guide: names another. Raises
NimbleOptions.ValidationError for an option it does not take, a colour CSS does not define or
one with an alpha of its own, and ArgumentError for a list of labels without a list of breaks
as long; a column that is not numbers is refused when the plot is run.
Options
:low- The colour the low side runs to, a dark red when not given. The default value is"#832424".:mid- The colour at the midpoint, white when not given. The default value is"#FFFFFF".:high- The colour the high side runs to, a dark blue when not given. The default value is"#3A3A98".:midpoint- The value the middle colour stands at. The default value is0.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "change" => [-2, 0, 1]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :change}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_gradient2() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#832424", "#FFFFFF", "#A197CC"]
Gives the plot a continuous colour scale, a gradient from low: to high:, replacing any colour
scale it had.
Each value takes the colour as far along the gradient as the value is through the limits,
blended in CIE Lab*, which spaces colours evenly to the eye; its guide is a colour bar unless
guide: names another. Raises NimbleOptions.ValidationError for an option it does not take, a
colour CSS does not define or one with an alpha of its own, and ArgumentError for a list of
labels without a list of breaks as long; a column that is not numbers is refused when the plot is
run.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [1, 2, 3]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_gradient(low: "white", high: "black") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FFFFFF", "#777777", "#000000"]
Gives the plot a continuous colour scale, a gradient through the colours of colors:, replacing
any colour scale it had.
The colours are spaced evenly over the limits, the first at the low end and the last at the high,
unless values: places them, and blended in CIE Lab* between neighbours; its guide is a colour
bar unless guide: names another. Raises NimbleOptions.ValidationError for an option it does
not take, a colour CSS does not define or one with an alpha of its own, and ArgumentError for
a list of labels without a list of breaks as long; a column that is not numbers is refused when
the plot is run.
Options
:colors- Required. The colours, a list, spaced evenly from the low end of the limits to the high unlessvalues:places them.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_gradientn(colors: ["red", "yellow", "blue"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FF0000", "#FFFF00", "#0000FF"]
Gives the plot a discrete colour scale of greys, replacing any colour scale it had.
The greys run from start: to end:, spaced evenly to the eye; a missing value is red.
Raises NimbleOptions.ValidationError for an option it does not take or a grey's level outside
0 to 1, and ArgumentError for a list of labels not one for each break or limit given; a column
of numbers is refused when the plot is run.
Options
:start- The first value's grey, from 0, black, to 1, white. The default value is0.2.:end- The last value's grey, from 0, black, to 1, white. The default value is0.8.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#FF0000".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_gray() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#989898", "#333333", "#CCCCCC"]
Gives the plot a discrete colour scale of hues spaced evenly round the colour wheel, all of one chroma and luminance, replacing any colour scale it had.
A discrete column mapped to colour gets these hues by default; the options choose others.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels not one for each break or limit given; a column of
numbers is refused when the plot is run.
Options
:hue-{first, last}: the hues the colours are spaced between, in degrees round the colour wheel. A range spanning the whole circle leaves its last share off, so the first and last colours differ. The default value is{15.0, 375.0}.:chroma- How vivid the colours are, from 0, grey. The default value is100.0.:luminance- How light the colours are, from 0, black, to 100, white. The default value is65.0.:direction- 1 to give the colours to the values in order, -1 in reverse. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_hue(luminance: 40, chroma: 30) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#3A6845", "#7F5351", "#515E7F"]
Gives the plot an identity colour scale, replacing any colour scale it had: each value is drawn
as the colour it names, unscaled; it draws no legend unless guide: asks for one.
Each value must be a colour colour: takes: a CSS colour name, such as "steelblue", a hex
colour, such as "#4682B4", or "#4682B480" with an alpha of its own, "transparent", or
:none for none; a missing one stays missing.
Given guide: :legend, its legend keys every value the data holds, sorted, or those breaks: names among limits:, each drawn
as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels not one for each break
or limit given; a value it cannot use, or beside a legend a column of numbers, is refused when
the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:limits- The values the legend shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value. Every value the data holds, in order, when not given. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the values the data holds, in order, that returns them.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7]} ...> |> Map.put("ink", ["red", "#0000FF", "steelblue"]) ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, color: :ink}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FF0000", "#0000FF", "#4682B4"]
Gives the plot a discrete colour scale of the colours given, replacing any colour scale it had.
values: gives the colours, a list handed to the values in order, or a map from a value to its
colour. The legend shows a key for each value the scale shows, labelled. Raises
NimbleOptions.ValidationError for an option it does not take or a colour CSS does not define,
and ArgumentError for a list of labels not one for each break or limit given; a column of
numbers, or more values than a list has colours, is refused when the plot is run.
Options
:values- Required. The colours: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its colour, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no colour takesna_value:.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_manual(values: %{"4" => "steelblue", "6" => "orange", "8" => "red"}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FFA500", "#4682B4", "#FF0000"]
Gives the plot a colour scale for ordered values, replacing any colour scale it had: a viridis
palette's colours, as scale_color_viridis_d/2 gives them, or a blend through the colours of
type:.
Given no type:, the values take colours spaced evenly from begin: to end: of the palette
option:, in their order; an ordered factor mapped to colour gets this scale by default. Given
type:, a list of colours, the first value takes the first colour, the last value the last,
and those between colours spaced evenly along a blend through the list, so two colours make a
run from one to the other for any number of values. A missing value has no colour, so its mark
is not drawn, unless na_value: gives one. Raises NimbleOptions.ValidationError for an option
it does not take or a value it cannot use, and ArgumentError for a viridis option given beside
type: or a list of labels not one for each break or limit given; a column of numbers is
refused when the plot is run.
Options
:type- A list of colours: the values take colours spaced evenly along a blend through them in CIE Lab*, the first value the first colour and the last the last, each colour's own alpha blended too, however many colours and values there are; the viridis options below are refused beside it. A viridis palette when not given.:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => [6, 4, 8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: {:factor, [:cyl], ordered: true}}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_ordinal(type: ["white", "darkred"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#D18978", "#FFFFFF", "#8B0000"]
Gives the plot a binned colour scale diverging from mid: at midpoint:, toward low: below
it and high: above, cut into steps, replacing any colour scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin takes the colour scale_color_gradient2/2 gives the bin's middle.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:low- The colour the low side runs to, a dark red when not given. The default value is"#832424".:mid- The colour at the midpoint, white when not given. The default value is"#FFFFFF".:high- The colour the high side runs to, a dark blue when not given. The default value is"#3A3A98".:midpoint- The value the middle colour stands at. The default value is0.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_steps2(midpoint: 120) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#EED9D6", "#C89089", "#6057A9"]
Gives the plot a binned colour scale, a gradient from low: to high: cut into steps, replacing
any colour scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin takes the colour of the gradient at the bin's middle, blended in CIE Lab*.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_steps(low: "white", high: "black") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#ABABAB", "#E2E2E2", "#1B1B1B"]
Gives the plot a binned colour scale, a gradient through the colours of colors: cut into steps,
replacing any colour scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin takes the colour scale_color_gradientn/2 gives the bin's middle.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:colors- Required. The colours, a list, spaced evenly from the low end of the limits to the high unlessvalues:places them.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_stepsn(colors: ["red", "yellow", "blue"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#FFB500", "#FF5F00", "#8A44DE"]
Gives the plot a binned colour scale from a viridis palette, replacing any colour scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and the bins
take the colours scale_color_viridis_d/2 would give as many values, in order, from begin:
to end: of the palette option:.
Raises NimbleOptions.ValidationError for an option it does not take or a value it cannot use,
and ArgumentError for a list of labels without a list of breaks as long, show_limits: true
beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers is
refused when the plot is run.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_viridis_b() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#3B528B", "#440154", "#FDE725"]
Gives the plot a continuous colour scale, a gradient through a viridis palette, replacing any colour scale it had.
The gradient runs through six colours spaced evenly from begin: to end: of the palette
option:, blended in CIE Lab* between neighbours, as scale_color_gradientn/2 blends its
colours; its guide is a colour bar unless guide: names another. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, and
ArgumentError for a list of labels without a list of breaks as long; a column that is not
numbers is refused when the plot is run.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_viridis_c() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#440154", "#2B9089", "#FDE725"]
Gives the plot a discrete colour scale from a viridis palette, replacing any colour scale it had.
The palettes change evenly to the eye, in colour and in grey, and are made to be read by people
with the common forms of colour blindness. The values take colours spaced evenly from begin:
to end: of the palette option:, in order. An ordered factor mapped to colour gets
this scale by default; a missing value has no colour, so its mark is not drawn, unless
na_value: gives one. Raises NimbleOptions.ValidationError for an option it does not take or
a value it cannot use, and ArgumentError for a list of labels not one for each break or limit
given; a column of numbers is refused when the plot is run.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, colour: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_color_viridis_d(option: :magma) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:color) ["#B63679", "#000004", "#FCFDBF"]
Gives the plot one continuous identity scale serving every aesthetic aesthetics names,
replacing any scale that served one of them: each value is drawn as the value it is, unscaled,
for each of the aesthetics alike; it draws no legend unless guide: asks for one.
aesthetics is an aesthetic other than position, or a list of them, :colour spelled
:color, in any mix. Each value must be one the option setting its aesthetic takes, as each
aesthetic's identity scale checks it; a missing one stays missing. Given guide: :legend, each
aesthetic's legend keys breaks chosen over the data's range, or over limits:, or those
breaks: gives, each drawn as its value. Raises ArgumentError for aesthetics it does not
take, or for a list of labels without a list of breaks as long, and
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them; a value it cannot use, or beside a legend a column that is not
numbers, is refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:limits-{low, high}: the values the legend spans whatever the data,nilfor an end the data decides; either order names the same scale. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "s" => [1, 3, 5], "a" => [0.2, 0.5, 1]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, size: :s, alpha: :a}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_continuous_identity([:size, :alpha]) iex> frame = Giggly.layer_data(plot) iex> {Giggly.DataFrame.pull(frame, :size), Giggly.DataFrame.pull(frame, :alpha)} {[1.0, 3.0, 5.0], [0.2, 0.5, 1.0]}
Gives the plot one discrete identity scale serving every aesthetic aesthetics names,
replacing any scale that served one of them: each value is drawn as the value it is, unscaled,
for each of the aesthetics alike; it draws no legend unless guide: asks for one.
aesthetics is an aesthetic other than position, or a list of them, :colour spelled
:color, in any mix. Each value must be one the option setting its aesthetic takes, as each
aesthetic's identity scale checks it; a missing one stays missing. Given guide: :legend, each
aesthetic's legend keys every value the data holds, sorted, or those breaks: names among
limits:, each drawn as its value. Raises ArgumentError for aesthetics it does not take, and
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them; a value it cannot use, or beside a legend a column of numbers,
is refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:limits- The values the legend shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value. Every value the data holds, in order, when not given. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the values the data holds, in order, that returns them.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "paint" => ["red", "green", "blue"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, color: :paint, fill: :paint}) ...> |> Giggly.Plot.geom_point(shape: 21) ...> |> Giggly.Plot.scale_discrete_identity([:color, :fill]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FF0000", "#008000", "#0000FF"]
Gives the plot one manual scale serving every aesthetic aesthetics names, replacing any scale
that served one of them: its values are handed to the data's values by hand, as the manual
scale of each aesthetic hands them, for each of the aesthetics alike.
aesthetics is an aesthetic other than position, or a list of them, :colour spelled
:color, that hold their values alike: :color and :fill; any of :alpha, :size and
:linewidth; :shape; or :linetype. The scale is trained once over every one of them, in the
order given, and each draws its own legend, titled by its own label; two titled alike, showing
the same keys, merge into one. values: gives the values, each checked as the option setting
every aesthetic named checks one: a list handed to the values in order, or a map from a value
to its value. Raises ArgumentError for aesthetics it does not take, or for a value one of
them refuses, and NimbleOptions.ValidationError for an option it does not take or a value it
cannot use; a column of numbers, or more values than a list has, is refused when the plot is
run.
Options
:values- Required. The values: a list, given to the data's values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its value, whose scale shows only the values the data holds that it names, unlesslimits:gives others. Each is checked as the option setting every aesthetic the scale serves checks one. A value with none takesna_value:.:na_value(term/0) - What a missing value, or one with no value, maps to, checked asvalues:are; none when not given, so its mark is not drawn.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, alpha: :cyl, size: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_discrete_manual([:alpha, :size], values: [0.2, 0.5, 1]) iex> frame = Giggly.layer_data(plot) iex> {Giggly.DataFrame.pull(frame, :alpha), Giggly.DataFrame.pull(frame, :size)} {[0.5, 0.2, 1.0], [0.5, 0.2, 1.0]}
Gives the plot a binned fill scale, replacing any fill scale it had, as scale_color_binned/2
gives a colour scale.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Blues"or"viridis", its colours for as many bins as there are given to them in order, or a list of colours, given to the bins in order, at least one for each; the theme'spalette_color_continuous:, or else a gradient from#132B43to#56B1F7, each bin the colour at its middle, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_binned(palette: "Blues") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#EFF3FF", "#BDD7E7", "#2171B5"]
Gives the plot a discrete fill scale from a ColorBrewer palette, replacing any fill scale it had,
as scale_color_brewer/2 gives a colour scale.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- 1 to give the palette's colours to the values in order, -1 in reverse. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r", "4"], "hwy" => [28, 19, 20]} ...> |> Giggly.Plot.new(%{x: :drv, y: :hwy, fill: :drv}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_brewer(type: :qual, palette: 2) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#D95F02", "#7570B3", "#1B9E77"]
Gives the plot a continuous fill scale, replacing any fill scale it had, as
scale_color_continuous/2 gives a colour scale.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Blues"or"viridis", its colours blended in order, or a list of colours, spaced evenly from the low end of the limits to the high; the theme'spalette_color_continuous:, or else a gradient from#132B43to#56B1F7, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_continuous(palette: ["#FEE0D2", "#FC9272", "#DE2D26"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FEE0D2", "#FC9272", "#DE2D26"]
Gives the plot a date fill scale, a gradient from low: to high:, replacing any fill scale
it had, as scale_color_date/2 gives a colour scale.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the dates the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The dates the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date, label}pairs, handed the limits,{low, high}, as dates, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[month: 3]: one of:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (Apr,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %Y". Not withlabels:.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "day" => [~D[2024-01-15], ~D[2024-05-01], ~D[2024-11-20]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :day}) ...> |> Giggly.Plot.geom_tile() ...> |> Giggly.Plot.scale_fill_date(low: "white", high: "black") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FFFFFF", "#9F9F9F", "#000000"]
Gives the plot a date-time fill scale, a gradient from low: to high:, replacing any fill
scale it had, as scale_color_datetime/2 gives a colour scale.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the date-times the scale spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The date-times the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date_time, label}pairs, handed the limits,{low, high}, as the column holds date-times, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of date-times as the column holds them, that returns a label for each, a string, a power ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:timezone(String.t/0) - The time zone the scale lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 09:00:00Z], ~U[2024-03-10 18:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :at}) ...> |> Giggly.Plot.geom_tile() ...> |> Giggly.Plot.scale_fill_datetime(low: "white", high: "black") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FFFFFF", "#777777", "#000000"]
Gives the plot a discrete fill scale, replacing any fill scale it had, as
scale_color_discrete/2 gives a colour scale.
Options
:palette- A palette's name, one of scales' in any case (Scales.Palette.named/1), such as"Set1"or"viridis", or a list of colours, its colours given to the values in order; the theme'spalette_color_discrete:, or else hues spaced evenly round the colour wheel, when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r", "4"], "hwy" => [28, 19, 20]} ...> |> Giggly.Plot.new(%{x: :drv, y: :hwy, fill: :drv}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_discrete(limits: ["f", "r"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#F8766D", "#00BFC4", "#7F7F7F"]
Gives the plot a continuous fill scale, a gradient through a ColorBrewer palette, replacing any
fill scale it had, as scale_color_distiller/2 gives a colour scale.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- -1 to blend the palette's colours from its last at the low end of the limits to its first at the high, 1 the other way. The default value is-1.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_distiller(palette: "YlGn") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#005A32", "#78C679", "#FFFFCC"]
Gives the plot a binned fill scale, from a ColorBrewer palette, replacing any fill scale it had, as
scale_color_fermenter/2 gives a colour scale.
Options
:type- The palettes a number inpalette:counts among::seq, sequential;:div, diverging; or:qual, qualitative. A name is not counted, so this is not read beside one. The default value is:seq.:palette- The ColorBrewer palette: its name, spelled asScales.Palette.brewer_palettes/1spells it, or its number among the palettes oftype:, counting from 1. The default value is1.:direction- -1 to give the palette's colours to the bins from its last at the lowest to its first at the highest, 1 the other way. The default value is-1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_fermenter(palette: "YlGn") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#238443", "#78C679", "#FFFFCC"]
Gives the plot a continuous fill scale diverging from mid: at midpoint:, replacing any fill
scale it had, as scale_color_gradient2/2 gives a colour scale.
Options
:low- The colour the low side runs to, a dark red when not given. The default value is"#832424".:mid- The colour at the midpoint, white when not given. The default value is"#FFFFFF".:high- The colour the high side runs to, a dark blue when not given. The default value is"#3A3A98".:midpoint- The value the middle colour stands at. The default value is0.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_gradient2(midpoint: 4) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#B26D65", "#E0DBEE", "#3A3A98"]
Gives the plot a continuous fill scale, a gradient from low: to high:, replacing any fill
scale it had, as scale_color_gradient/2 gives a colour scale.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_gradient(low: "white", high: "steelblue") iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FFFFFF", "#A7BED9", "#4682B4"]
Gives the plot a continuous fill scale, a gradient through the colours of colors:, replacing
any fill scale it had, as scale_color_gradientn/2 gives a colour scale.
Options
:colors- Required. The colours, a list, spaced evenly from the low end of the limits to the high unlessvalues:places them.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_gradientn(colors: ["#FEE0D2", "#FC9272", "#DE2D26"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FEE0D2", "#FC9272", "#DE2D26"]
Gives the plot a discrete fill scale of greys, replacing any fill scale it had, as
scale_color_gray/2 gives a colour scale.
Options
:start- The first value's grey, from 0, black, to 1, white. The default value is0.2.:end- The last value's grey, from 0, black, to 1, white. The default value is0.8.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#FF0000".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r"], "hwy" => [28, 19]} ...> |> Giggly.Plot.new(%{x: :drv, y: :hwy, fill: :drv}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_gray(start: 0, end: 1) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#000000", "#FFFFFF"]
Gives the plot a discrete fill scale of hues spaced evenly round the colour wheel, replacing any
fill scale it had, as scale_color_hue/2 gives a colour scale.
Options
:hue-{first, last}: the hues the colours are spaced between, in degrees round the colour wheel. A range spanning the whole circle leaves its last share off, so the first and last colours differ. The default value is{15.0, 375.0}.:chroma- How vivid the colours are, from 0, grey. The default value is100.0.:luminance- How light the colours are, from 0, black, to 100, white. The default value is65.0.:direction- 1 to give the colours to the values in order, -1 in reverse. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"cyl" => ["6", "4", "8"], "mpg" => [19.7, 26.7, 15.1]} ...> |> Giggly.Plot.new(%{x: :cyl, y: :mpg, fill: :cyl}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_hue(direction: -1) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#00BA38", "#619CFF", "#F8766D"]
Gives the plot an identity fill scale, replacing any fill scale it had: each value is drawn as
the colour it names, unscaled; it draws no legend unless guide: asks for one.
Each value must be a colour, as scale_color_identity/2 takes one.
Given guide: :legend, its legend keys every value the data holds, sorted, or those breaks: names among limits:, each drawn
as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels not one for each break
or limit given; a value it cannot use, or beside a legend a column of numbers, is refused when
the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:limits- The values the legend shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value. Every value the data holds, in order, when not given. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the values the data holds, in order, that returns them.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "paint" => ["red", "green", "blue"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, fill: :paint}) ...> |> Giggly.Plot.geom_tile() ...> |> Giggly.Plot.scale_fill_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FF0000", "#008000", "#0000FF"]
Gives the plot a discrete fill scale of the colours given, replacing any fill scale it had, as
scale_color_manual/2 gives a colour scale.
Options
:values- Required. The colours: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its colour, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no colour takesna_value:.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r"], "hwy" => [28, 19]} ...> |> Giggly.Plot.new(%{x: :drv, y: :hwy, fill: :drv}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_manual(values: ["steelblue", "orange"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#4682B4", "#FFA500"]
Gives the plot a fill scale for ordered values, replacing any fill scale it had, as
scale_color_ordinal/2 gives a colour scale.
Options
:type- A list of colours: the values take colours spaced evenly along a blend through them in CIE Lab*, the first value the first colour and the last the last, each colour's own alpha blended too, however many colours and values there are; the viridis options below are refused beside it. A viridis palette when not given.:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r", "4"], "hwy" => [28, 19, 20]} ...> |> Giggly.Plot.new(%{ ...> x: :drv, ...> y: :hwy, ...> fill: {:factor, [:drv], levels: ["f", "r", "4"], ordered: true} ...> }) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_ordinal(option: :magma) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#000004", "#B63679", "#FCFDBF"]
Gives the plot a binned fill scale, diverging from mid: at midpoint:, cut into steps, replacing any fill scale it had, as
scale_color_steps2/2 gives a colour scale.
Options
:low- The colour the low side runs to, a dark red when not given. The default value is"#832424".:mid- The colour at the midpoint, white when not given. The default value is"#FFFFFF".:high- The colour the high side runs to, a dark blue when not given. The default value is"#3A3A98".:midpoint- The value the middle colour stands at. The default value is0.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_steps2(midpoint: 4) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#CD9993", "#FBF5F5", "#685FAE"]
Gives the plot a binned fill scale, a gradient cut into steps, replacing any fill scale it had, as
scale_color_steps/2 gives a colour scale.
Options
:low- The colour at the low end of the limits. The default value is"#132B43".:high- The colour at the high end of the limits. The default value is"#56B1F7".:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_steps(n_breaks: 3) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#22496C", "#22496C", "#448DC6"]
Gives the plot a binned fill scale, a gradient through colors: cut into steps, replacing any fill scale it had, as
scale_color_stepsn/2 gives a colour scale.
Options
:colors- Required. The colours, a list, spaced evenly from the low end of the limits to the high unlessvalues:places them.:values- Where the colours sit: places from 0, the low end of the limits, to 1, the high, one for each colour, so each colour sits at its place and those between are blended; of another count, the colours are spread over them evenly. A value beyond the first or last place takesna_value:. The colours are spaced evenly when not given.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_stepsn( ...> colors: ["#FEE0D2", "#FC9272", "#DE2D26"], ...> nice_breaks: false ...> ) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FFD3C1", "#FE9F81", "#E44332"]
Gives the plot a binned fill scale, from a viridis palette, replacing any fill scale it had, as
scale_color_viridis_b/2 gives a colour scale.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takes the colour of the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside takes the colour of the bin at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether colour steps label the ends of the bar with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::colorsteps, a bar of one block of colour for each bin, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorsteps.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_viridis_b(option: :plasma) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#0D0887", "#9C179E", "#F0F921"]
Gives the plot a continuous fill scale, a gradient through a viridis palette, replacing any fill
scale it had, as scale_color_viridis_c/2 gives a colour scale.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is"#7F7F7F".:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::colorbar, a bar the colours run up, or{:colorbar, options};:colorsteps, a bar of one block of colour between each break and the next, or{:colorsteps, options};:bins, a key for each bin, or{:bins, options};:legend, a key for each break; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:colorbar.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [0, 5, 10]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, fill: :hp}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_viridis_c(option: :plasma, begin: 0.2) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#6A00A8", "#E06663", "#F0F921"]
Gives the plot a discrete fill scale from a viridis palette, replacing any fill scale it had, as
scale_color_viridis_d/2 gives a colour scale.
Options
:option- The palette::viridis,:magma,:inferno,:plasma,:cividis,:rocket,:makoor:turbo. The default value is:viridis.:begin- Where in the palette the colours begin, from 0, its start, to 1, its end. The default value is0.0.:end- Where in the palette the colours end, from 0, its start, to 1, its end. The default value is1.0.:direction- 1 to take the colours frombegin:toend:, -1 fromend:tobegin:. The default value is1.:alpha- The colours' opacity, from 0 to 1. The default value is1.0.:na_value- The colour of a missing value, or of one outside the limits, or:nonefor none, which draws nothing. The default value is:none.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"drv" => ["f", "r"], "hwy" => [28, 19]} ...> |> Giggly.Plot.new(%{x: :drv, y: :hwy, fill: :drv}) ...> |> Giggly.Plot.geom_col() ...> |> Giggly.Plot.scale_fill_viridis_d(direction: -1) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:fill) ["#FDE725", "#440154"]
Gives the plot a binned line type scale, replacing any line type scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and the bins
take the 13 line types scale_linetype_discrete/2 gives, in order from the lowest: solid, then
the dash patterns {2, 2}, {4, 2}, {4, 4}, {1, 3}, {1, 3, 4, 3} and on. Line types have
no order, so the bins' line types say only which bin a value is in. Values outside the limits
take the line type of the nearer end bin, unless oob: says otherwise, and a missing value
draws no line unless na_value: gives it a line type. Its guide is a binned legend, a key for
each bin, unless guide: says otherwise. Raises NimbleOptions.ValidationError for an option
it does not take or a value it cannot use, a guide: of :colorbar or :colorsteps among
them, and ArgumentError for a list of labels without a list of breaks as long, show_limits: true beside a list of labels, or n_breaks: 1 for nice breaks; a column that is not numbers,
or more than 13 bins, is refused when the plot is run.
Options
:na_value- The line type of a missing value, or of oneoob:leaves outside the limits::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside is binned at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether a binned legend labels its ends with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.iex> plot = ...> %{"start" => [1, 2, 3], "end" => [2, 3, 4], "y" => [1, 2, 3], "hp" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :start, xend: :end, y: :y, yend: :y, linetype: :hp}) ...> |> Giggly.Plot.geom_segment() ...> |> Giggly.Plot.scale_linetype_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linetype) [{}, {4, 2}, {1, 3, 4, 3}]
Gives the plot a discrete line type scale, replacing any line type scale it had.
The values are drawn in 13 line types, in order, easy to tell apart: solid, then the dash
patterns {2, 2}, {4, 2}, {4, 4}, {1, 3}, {1, 3, 4, 3}, {7, 3}, {2, 2, 6, 2},
{1, 2, 2, 2, 3, 2, 4, 2}, {15, 2, 8, 2}, {15, 4, 4, 4, 8, 4, 4, 4},
{2, 2, 4, 2, 8, 2, 15, 2} and {15, 1}, unless the theme's palette_linetype_discrete:
(theme/2) gives others. Line types have no order, so a continuous column takes
a line type scale only binned, by scale_linetype_binned/2. Its guide is a legend unless
guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide: of :colorbar or :colorsteps among them, and ArgumentError for a list of labels not
one for each break or limit given; a continuous column, or more than 13 values, is refused when
the plot is run, and scale_linetype_manual/2 gives as many line types as a scale has values.
Options
:na_value- The line type of a missing value, or of one not among the limits::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"month" => [1, 2, 1, 2], "value" => [0.2, 0.4, 0.9, 0.7], "series" => ["pce", "pce", "pop", "pop"]} ...> |> Giggly.Plot.new(%{x: :month, y: :value, linetype: :series}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linetype_discrete(limits: ["pop", "pce"]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linetype) [{2, 2}, {2, 2}, {}, {}]
Gives the plot an identity line type scale, replacing any line type scale it had: each value is
drawn as the line type it names, unscaled; it draws no legend unless guide: asks for one.
Each value must be a line type by name, as linetype: takes one, :dashed, or by its number,
0 to 6, or a string as R writes one: a name, "dashed", or a dash pattern of 2, 4, 6 or 8 hex
digits from 1 to F, a dash and a gap in turn, "44" being linetype: {4, 4}; a missing one
stays missing.
Given guide: :legend, its legend keys every value the data holds, sorted, or those breaks: names among limits:, each drawn
as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels not one for each break
or limit given; a value it cannot use, or beside a legend a column of numbers, is refused when
the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:limits- The values the legend shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value. Every value the data holds, in order, when not given. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the values the data holds, in order, that returns them.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"x" => [1, 2, 1, 2], "y" => [1, 1, 2, 2], "dash" => ["13", "13", "dashed", "dashed"]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, linetype: :dash}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linetype_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linetype) [{1, 3}, {1, 3}, {4, 4}, {4, 4}]
Gives the plot a discrete line type scale of the line types given, replacing any line type scale it had.
values: gives the line types, each by name, by its number or as a dash pattern, as
geom_line/3's linetype: takes one: a list handed to the values in order, or a map from a
value to its line type. The legend shows a key for each value the scale shows, labelled. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a line
type no line is drawn in or a guide: of :colorbar or :colorsteps among them, and
ArgumentError for a list of labels not one for each break or limit given; a continuous column,
or more values than a list has line types, is refused when the plot is run.
Options
:values- Required. The line types, each:blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its line type, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no line type takesna_value:.:na_value- The line type of a missing value, or of one not among the limits::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"month" => [1, 2, 1, 2], "value" => [0.2, 0.4, 0.9, 0.7], "series" => ["pce", "pce", "pop", "pop"]} ...> |> Giggly.Plot.new(%{x: :month, y: :value, linetype: :series}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linetype_manual(values: %{"pce" => :dotted, "pop" => {3, 1}}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linetype) [{1, 3}, {1, 3}, {3, 1}, {3, 1}]
Gives the plot a binned line width scale, replacing any line width scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin is drawn at one width, in millimetres, as far from the first of range: to the second
as the bin's middle is through the limits. Values outside the limits take the width of the
nearer end bin, and a missing value draws no line. Its guide is a binned legend, a key for each
bin, unless guide: says otherwise. Raises NimbleOptions.ValidationError for an option it does
not take or a value it cannot use, a width below 0 or a guide: of :colorbar or
:colorsteps, and ArgumentError for a list of labels without a list of breaks as long, or
n_breaks: 1 for nice breaks; a column that is not numbers is refused when the plot is run.
Options
:range-{low, high}: the widths, in millimetres, the values run between, each 0 or more; the theme'spalette_linewidth_continuous:, or else 1 to 6, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.iex> plot = ...> %{"month" => [1, 2, 3], "unemploy" => [2944, 2945, 2958], "uempmed" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :month, y: :unemploy, linewidth: :uempmed}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linewidth_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [1.4166666666666665, 3.083333333333333, 5.583333333333334]
Gives the plot a continuous line width scale, replacing any line width scale it had.
Each value's line is drawn at a width between the first of range: and the second, in
millimetres, as far between them as the value is through the limits. A line whose width changes
along it is drawn a segment from each row to the next, each as wide as the row it starts from.
Its guide is a legend unless guide: says otherwise. A value outside the limits, or missing,
draws no line, and an infinite one is an infinite width, which raises when the plot is drawn. Raises NimbleOptions.ValidationError for an option it does not take or a value
it cannot use, a width below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError
for a list of labels without a list of breaks as long; a column that is not numbers is refused
when the plot is run.
Options
:range-{low, high}: the widths, in millimetres, the values run between, each 0 or more; the theme'spalette_linewidth_continuous:, or else 1 to 6, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them draws no line. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"month" => [1, 2, 3], "unemploy" => [2944, 2945, 2958], "uempmed" => [4.5, 4.7, 4.6]} ...> |> Giggly.Plot.new(%{x: :month, y: :unemploy, linewidth: :uempmed}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linewidth_continuous(range: {0, 4}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [0.0, 4.0, 1.9999999999999911]
Gives the plot a date line width scale, each date's width as far through the limits as the
date is, on range:, replacing any line width scale it had.
Its legend keys dates on calendar boundaries, as scale_color_date/2's colour bar marks them;
a date outside the limits, or missing, takes na_value:, none, drawing no line, when not
given. Raises ArgumentError for an option given beside its date_ twin, or a list of labels
without a list of breaks as long; a column that is not dates is refused when the plot is run.
Options
:range-{low, high}: the widths, in millimetres, the values run between, each 0 or more; the theme'spalette_linewidth_continuous:, or else 1 to 6, when not given.:na_value- The width, in millimetres, of a missing value, or of one not among the limits, 0 or more; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the dates the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The dates the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date, label}pairs, handed the limits,{low, high}, as dates, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[month: 3]: one of:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (Apr,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %Y". Not withlabels:.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "day" => [~D[2024-01-15], ~D[2024-05-01], ~D[2024-11-20]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, linewidth: :day}) ...> |> Giggly.Plot.geom_path() ...> |> Giggly.Plot.scale_linewidth_date(range: {0, 4}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [0.0, 1.3806451612903226, 4.0]
Gives the plot a date-time line width scale, each date-time's width as far through the limits
as it is, on range:, replacing any line width scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Options
:range-{low, high}: the widths, in millimetres, the values run between, each 0 or more; the theme'spalette_linewidth_continuous:, or else 1 to 6, when not given.:na_value- The width, in millimetres, of a missing value, or of one not among the limits, 0 or more; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the date-times the scale spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The date-times the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date_time, label}pairs, handed the limits,{low, high}, as the column holds date-times, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of date-times as the column holds them, that returns a label for each, a string, a power ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:timezone(String.t/0) - The time zone the scale lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 09:00:00Z], ~U[2024-03-10 18:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, linewidth: :at}) ...> |> Giggly.Plot.geom_path() ...> |> Giggly.Plot.scale_linewidth_datetime(range: {0, 4}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [0.0, 2.0, 4.0]
Gives the plot a discrete line width scale, replacing any line width scale it had.
The values' lines are drawn at widths spaced evenly from the first of range: to the second, in
millimetres, in order. Its guide is a legend unless guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a width
below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError for a list of labels
not one for each break or limit given; a column of numbers is refused when the plot is run.
Options
:range-{first, last}: the widths, in millimetres, of the first and last values, each 0 or more; the theme'spalette_linewidth_discrete:, or else 2 to 6, when not given.:na_value- The width, in millimetres, of a missing value, or of one not among the limits, 0 or more; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"class" => ["suv", "compact", "pickup"], "hwy" => [18, 28, 16]} ...> |> Giggly.Plot.new(%{x: :class, y: :hwy, linewidth: :class}) ...> |> Giggly.Plot.geom_col(colour: "black") ...> |> Giggly.Plot.scale_linewidth_discrete(range: {1, 3}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [3.0, 1.0, 2.0]
Gives the plot an identity line width scale, replacing any line width scale it had: each value
is drawn as the width it is, in millimetres, unscaled; it draws no legend unless guide: asks for one.
Each value must be a width linewidth: takes, 0 or more; a missing one stays missing.
Given guide: :legend, its legend keys breaks chosen over the data's range, or over limits:, or those breaks: gives, each
drawn as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels without a list of
breaks as long; a value it cannot use, or beside a legend a column that is not numbers, is
refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:limits-{low, high}: the values the legend spans whatever the data,nilfor an end the data decides; either order names the same scale. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"x" => [1, 2, 3, 4], "y" => [1, 1, 2, 2], "width" => [0.5, 0.5, 2, 2]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, linewidth: :width}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_linewidth_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [0.5, 0.5, 2.0, 2.0]
Gives the plot a discrete line width scale of the widths given, replacing any line width scale it had.
values: gives the widths, in millimetres, each 0 or more: a list handed to the values in
order, or a map from a value to its width. The legend shows a key for each value the scale
shows, labelled. Raises NimbleOptions.ValidationError for an option it does not take or a
value it cannot use, a width below 0 or a guide: of :colorbar or :colorsteps among them,
and ArgumentError for a list of labels not one for each break or limit given; a column of
numbers, or more values than a list has widths, is refused when the plot is run.
Options
:values- Required. The widths, each in millimetres, 0 or more: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its width, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no width takesna_value:.:na_value- The width, in millimetres, of a missing value, or of one not among the limits, 0 or more; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"class" => ["suv", "compact", "pickup"], "hwy" => [18, 28, 16]} ...> |> Giggly.Plot.new(%{x: :class, y: :hwy, linewidth: :class}) ...> |> Giggly.Plot.geom_col(colour: "black") ...> |> Giggly.Plot.scale_linewidth_manual(values: [0.5, 1, 2]) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [2.0, 0.5, 1.0]
Gives the plot a line width scale for ordered values, replacing any line width scale it had:
the scale scale_linewidth_discrete/2 gives, with its options.
The values' lines are drawn at widths spaced evenly from the first of range: to the second, in
millimetres, in their order. Its guide is a legend unless guide: says otherwise. An ordered
factor mapped to line width gets this scale by default. Raises NimbleOptions.ValidationError
for an option it does not take or a value it cannot use, a width below 0 or a guide: of
:colorbar or :colorsteps, and ArgumentError for a list of labels not one for each break
or limit given; a column of numbers is refused when the plot is run.
Options
:range-{first, last}: the widths, in millimetres, of the first and last values, each 0 or more; the theme'spalette_linewidth_discrete:, or else 2 to 6, when not given.:na_value- The width, in millimetres, of a missing value, or of one not among the limits, 0 or more; none, which draws no line, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"size" => ["small", "large", "medium"], "hwy" => [28, 16, 18]} ...> |> Giggly.Plot.new(%{ ...> x: :size, ...> y: :hwy, ...> linewidth: {:factor, [:size], levels: ["small", "medium", "large"], ordered: true} ...> }) ...> |> Giggly.Plot.geom_col(colour: "black") ...> |> Giggly.Plot.scale_linewidth_ordinal(range: {1, 3}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:linewidth) [1.0, 3.0, 2.0]
Gives the plot a continuous size scale by width, replacing any size scale it had.
Each value is drawn at a size between the first of range: and the second, in millimetres, as
far between them as the value is through the limits, so a point's width, not its area, grows
with the value. Its guide is a legend unless guide: says otherwise. A value outside the limits,
or missing, is not drawn. Raises NimbleOptions.ValidationError for an option it does not take
or a value it cannot use, a size below 0 or a guide: of :colorbar or :colorsteps, and
ArgumentError for a list of labels without a list of breaks as long; a column that is not
numbers is refused when the plot is run.
Options
:range-{low, high}: the sizes, in millimetres, the values run between, each 0 or more. The default value is{1.0, 6.0}.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is not drawn. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_radius(range: {2, 8}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [3.2439024390243905, 2.0, 8.0]
Gives the plot a binned shape scale, replacing any shape scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and the bins
take the six shapes scale_shape_discrete/2 gives, in order from the lowest: solid,
:circle_small, :triangle, :square, :plus, :square_cross and :asterisk, or, with
solid: false, the first three open. Shapes have no order, so the bins' shapes say only which
bin a value is in. Values outside the limits take the shape of the nearer end bin, unless oob:
says otherwise, and a missing value is not drawn unless na_value: gives it a shape. Its guide
is a binned legend, a key for each bin, unless guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide: of :colorbar or :colorsteps among them, and ArgumentError for a list of labels
without a list of breaks as long, show_limits: true beside a list of labels, or n_breaks: 1
for nice breaks; a column that is not numbers, or more than six bins, is refused when the plot
is run.
Options
:solid(boolean/0) - Whether the shapes are solid,:circle_small,:triangle,:square,:plus,:square_crossand:asteriskin order, or,false, open,:circle_open,:triangle_open,:square_openand the last three. The default value istrue.:na_value- The shape of a missing value, or of oneoob:leaves outside the limits, by name or by number, or:none; none, which draws no point, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside is binned at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether a binned legend labels its ends with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, shape: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_shape_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:shape) [:circle_small, :square, :asterisk]
Gives the plot a discrete shape scale, replacing any shape scale it had.
The values are drawn in six shapes, in order, easy to tell apart: solid, :circle_small,
:triangle, :square, :plus, :square_cross and :asterisk, or, with solid: false, the
first three open, :circle_open, :triangle_open and :square_open; given no solid:, the
theme's palette_shape_discrete: (theme/2) where it sets one. Shapes have no order, so a
continuous column takes a shape scale only binned, by scale_shape_binned/2. Its guide is a
legend unless guide: says otherwise. Raises NimbleOptions.ValidationError for an option it
does not take or a value it cannot use, a guide: of :colorbar or :colorsteps among them,
and ArgumentError for a list of labels not one for each break or limit given; a continuous
column, or more than six values, is refused when the plot is run, and scale_shape_manual/2
gives as many shapes as a scale has values.
Options
:solid(boolean/0) - Whether the shapes are solid,:circle_small,:triangle,:square,:plus,:square_crossand:asteriskin order, or,false, open,:circle_open,:triangle_open,:square_openand the last three. The theme'spalette_shape_discrete:, or else the solid shapes, when not given.:na_value- The shape of a missing value, or of one not among the limits, by name or by number, or:none; none, which draws no point, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, shape: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_shape_discrete(solid: false) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:shape) [:triangle_open, :circle_open, :square_open]
Gives the plot an identity shape scale, replacing any shape scale it had: each value is drawn as
the shape it names, unscaled; it draws no legend unless guide: asks for one.
Each value must be a shape shape: takes, a name or its number, 0 to 25, or :none, or a
shape's whole name as R writes one, with spaces for underscores, "circle filled", or
"triangle square" for :square_triangle; a missing one stays missing.
Given guide: :legend, its legend keys breaks chosen over the data's range, or over limits:, or those breaks: gives, each
drawn as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels without a list of
breaks as long; a value it cannot use, or beside a legend a column that is not numbers, is
refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:limits-{low, high}: the values the legend spans whatever the data,nilfor an end the data decides; either order names the same scale. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "pch" => [1, 21, 24]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, shape: :pch}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_shape_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:shape) [:circle_open, :circle_filled, :triangle_filled]
Gives the plot a discrete shape scale of the shapes given, replacing any shape scale it had.
values: gives the shapes, each by name or by its number, as geom_point/3 names them: a list
handed to the values in order, or a map from a value to its shape. The legend shows a key for
each value the scale shows, labelled. Raises NimbleOptions.ValidationError for an option it
does not take or a value it cannot use, a shape no point is drawn in or a guide: of
:colorbar or :colorsteps among them, and ArgumentError for a list of labels not one for each
break or limit given; a continuous column, or more values than a list has shapes, is refused when
the plot is run.
Options
:values- Required. The shapes, each by name, by number, a character or:none: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its shape, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no shape takesna_value:.:na_value- The shape of a missing value, or of one not among the limits, by name or by number, or:none; none, which draws no point, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, shape: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_shape_manual(values: %{"4" => 21, "6" => :diamond, "8" => 4}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:shape) [:diamond, :circle_filled, :cross]
Gives the plot a continuous size scale that draws 0 at size 0, replacing any size scale it had.
Each value is drawn at a size, in millimetres, whose square is as far toward the square of
max_size: as the value is toward the high end of the limits from 0, so a point's area is in
proportion to the value, and the high end is drawn at max_size:. A value below 0 is drawn as
large as its distance from 0, and an infinite value at an infinite size, so it is not drawn.
Its guide is a legend unless guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a size
below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError for a list of labels
without a list of breaks as long; a column that is not numbers, and a value below limits whose
high end is 0, which would be drawn infinitely large, are refused when the plot is run.
Options
:max_size- The size, in millimetres, of a value at the high end of the limits, 0 or more. The default value is6.0.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise where the scale takes it. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_area(max_size: 10) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [7.928249671720918, 7.289914755527471, 10.0]
Gives the plot a binned size scale, replacing any size scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin is drawn at one size between the first of range: and the second, in millimetres, by
area: its square as far between theirs as the bin's middle is through the limits. Values
outside the limits take the size of the nearer end bin, and a missing value is not drawn. Its
guide is a binned legend, a key for each bin, unless guide: says otherwise. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a size
below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError for a list of labels
without a list of breaks as long, or n_breaks: 1 for nice breaks; a column that is not numbers
is refused when the plot is run.
Options
:range-{low, high}: the sizes, in millimetres, the values run between by area, each 0 or more; the theme'spalette_size_continuous:, or else 1 to 6, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [2.4433756729740645, 4.2274861218395134, 5.7871355387816905]
Gives the plot a binned size scale that draws 0 at size 0, replacing any size scale it had.
The values are cut into bins at its breaks, as scale_color_binned/2 cuts them, and every value
in a bin is drawn at one size, in millimetres, whose square is as far toward the square of
max_size: as the bin's middle is toward the high end of the limits from 0, so a point's area
is in proportion to it. A bin below 0 is drawn as large as its middle's distance from 0; under
limits whose high end is below 0 the bins' sizes come in reverse, the lowest values drawn at the
size the highest values' places give, as R draws them. Values outside the limits take the size
of the nearer end bin, unless oob: says otherwise. Its guide is a binned legend, a key for
each bin, unless guide: says otherwise. Raises NimbleOptions.ValidationError for an option it
does not take or a value it cannot use, a size below 0 or a guide: of :colorbar or
:colorsteps, and ArgumentError for a list of labels without a list of breaks as long,
show_limits: true beside a list of labels, or n_breaks: 1 for nice breaks; a column that is
not numbers, and limits whose high end is 0, are refused when the plot is run.
Options
:max_size- The size, in millimetres, of a value at the high end of the limits, 0 or more. The default value is6.0.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is binned at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:.:squishwhen not given, so a value outside is binned at the nearer end.:breaks- The values the bins are cut at, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin and no guide; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer, the transformation's own number, five for every built-in one, when not given; 1 or more otherwise, 5 when not given; or of abreaks:function of two arguments, handed 5 when not given. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number, nor besidetransform:a span of time, whose breaks count none.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether a binned legend labels its ends with the limits, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:bins.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [52, 175, 335]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_binned_area() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [2.7774602993176543, 4.242640687119286, 5.7817446699565895]
Gives the plot a continuous size scale, replacing any size scale it had.
Each value is drawn at a size between the first of range: and the second, in millimetres, by
area: its size's square is as far between theirs as the value is through the limits, so a
point's area grows with the value. Its guide is a legend unless guide: says otherwise. A value
outside the limits, or missing, is not drawn. Raises NimbleOptions.ValidationError for an
option it does not take or a value it cannot use, a size below 0 or a guide: of :colorbar or
:colorsteps, and ArgumentError for a list of labels without a list of breaks as long; a column
that is not numbers is refused when the plot is run.
Options
:range-{low, high}: the sizes, in millimetres, the values run between by area, each 0 or more; the theme'spalette_size_continuous:, or else 1 to 6, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the values the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them is not drawn. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "hp" => [110, 93, 175]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :hp}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_continuous(range: {1, 10}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [5.097887617642688, 1.0, 10.0]
Gives the plot a date size scale, each date's area as far through the limits as the date is,
on range:, replacing any size scale it had.
Its legend keys dates on calendar boundaries, as scale_color_date/2's colour bar marks them;
a date outside the limits, or missing, takes na_value:, none, drawing no point, when not
given. Raises ArgumentError for an option given beside its date_ twin, or a list of labels
without a list of breaks as long; a column that is not dates is refused when the plot is run.
Options
:range-{low, high}: the sizes, in millimetres, the values run between by area, each 0 or more; the theme'spalette_size_continuous:, or else 1 to 6, when not given.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the dates the scale spans whatever the data,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The dates the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date, label}pairs, handed the limits,{low, high}, as dates, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[month: 3]: one of:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (Apr,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %Y". Not withlabels:.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "day" => [~D[2024-01-15], ~D[2024-05-01], ~D[2024-11-20]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, size: :day}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_date(range: {1, 10}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [1.0, 6.287538606585207, 10.0]
Gives the plot a date-time size scale, each date-time's area as far through the limits as it
is, on range:, replacing any size scale it had, its legend keying date-times as
scale_color_datetime/2's colour bar marks them. Raises ArgumentError for an option given beside its date_ twin, a list of labels without
a list of breaks as long, or a time zone the database does not know; a column that is not
date-times, or is in a zone the database does not know, or naive beside timezone:, is refused
when the plot is run.
Options
:range-{low, high}: the sizes, in millimetres, the values run between by area, each 0 or more; the theme'spalette_size_continuous:, or else 1 to 6, when not given.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits-{low, high}: the date-times the scale spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same scale. A value outside them takesna_value:, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, takesna_value:, but an opacity or a size kept outside runs on past its range.:censorwhen not given.:rescaler- How a value is placed between the limits, from 0 at the low end to 1 at the high, onceoob:has run, both in transformed space::rescale, its distance from the low end over the limits' width;{:mid, midpoint}, its distance frommidpoint, in transformed space, over the further end's, so the midpoint is at the middle;:max, its share of the high end; or a function handed the values and the limits,{low, high}, that returns a place for each, a number, an infinity,nilor:nan. A place beyond 0 to 1 is mapped as oneoob:leaves outside.:rescalewhen not given.:breaks- The date-times the legend or colour bar marks, a list, those outside the limits left out; a function that returns them, or{date_time, label}pairs, handed the limits,{low, high}, as the column holds date-times, and, taking two arguments,[]; or:nonefor no guide; chosen from the limits when neither this nordate_breaks:is given.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the limits' start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to their end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of date-times as the column holds them, that returns a label for each, a string, a power ornil; or:nonefor no labels. Not withdate_labels:. When neither is given, the breaks the scale chooses are written as suits their step over the limits (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:timezone(String.t/0) - The time zone the scale lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:guide- What reads the scale back::legend, a key for each break;:bins, a key for each bin between one break and the next, or{:bins, options}; or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"x" => [1, 2, 3], "y" => [1, 2, 3], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 09:00:00Z], ~U[2024-03-10 18:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, size: :at}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_datetime(range: {1, 10}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [1.0, 7.3639610306789285, 10.0]
Gives the plot a discrete size scale, replacing any size scale it had.
The values are drawn at sizes from the first of range: to the second, in millimetres, in
order, their squares, and so a point's area, evenly spaced. Its guide is a legend unless guide:
says otherwise. Raises NimbleOptions.ValidationError for an option it does not take or a value
it cannot use, a size below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError
for a list of labels not one for each break or limit given; a column of numbers is refused when
the plot is run.
Options
:range-{first, last}: the sizes, in millimetres, of the first and last values, each 0 or more; the theme'spalette_size_discrete:, or else 2 to 6, when not given.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_discrete(range: {1, 3}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [2.23606797749979, 1.0, 3.0]
Gives the plot an identity size scale, replacing any size scale it had: each value is drawn as
the size it is, in millimetres, unscaled; it draws no legend unless guide: asks for one.
Each value must be a size size: takes, 0 or more; a missing one stays missing.
Given guide: :legend, its legend keys breaks chosen over the data's range, or over limits:, or those breaks: gives, each
drawn as its value; the limits choose the keys, never the values drawn. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a
guide but a legend among them, and ArgumentError for a list of labels without a list of
breaks as long; a value it cannot use, or beside a legend a column that is not numbers, is
refused when the plot is run.
Options
:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:breaks- The values the legend or colour bar marks, a list of numbers, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given; or:nonefor no guide; chosen from the limits when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, 2 or more, of the breaks chosen whenbreaks:is not given, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:limits-{low, high}: the values the legend spans whatever the data,nilfor an end the data decides; either order names the same scale. The values drawn are never changed: the limits choose the legend's keys alone. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:guide- What reads the scale back::none, no guide;:legend, a key for each break, each drawn as its value, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot).guides/2draws one over it only where this one is a legend, since a scale with no guide learns no values. The default value is:none.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => [6, 4, 8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_identity() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [6.0, 4.0, 8.0]
Gives the plot a discrete size scale of the sizes given, replacing any size scale it had.
values: gives the sizes, in millimetres, each 0 or more: a list handed to the values in order,
or a map from a value to its size. The legend shows a key for each value the scale shows,
labelled. Raises NimbleOptions.ValidationError for an option it does not take or a value it
cannot use, a size below 0 or a guide: of :colorbar or :colorsteps among them, and
ArgumentError for a list of labels not one for each break or limit given; a column of
numbers, or more values than a list has sizes, is refused when the plot is run.
Options
:values- Required. The sizes, each in millimetres, 0 or more: a list, given to the values in order, or tobreaks:in order where they are a list; or a map from a value, as the column holds it, to its size, whose scale shows only the values the data holds that it names, unlesslimits:gives others. A value with no size takesna_value:.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => ["6", "4", "8"]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: :cyl}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_manual(values: %{"4" => 1, "6" => 3, "8" => 5}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [3.0, 1.0, 5.0]
Gives the plot a size scale for ordered values, replacing any size scale it had: the scale
scale_size_discrete/2 gives, with its options.
The values are drawn at sizes from the first of range: to the second, in millimetres, in their
order, their squares, and so a point's area, evenly spaced. Its guide is a legend unless
guide: says otherwise. An ordered factor mapped to size gets this scale by default. Raises
NimbleOptions.ValidationError for an option it does not take or a value it cannot use, a size
below 0 or a guide: of :colorbar or :colorsteps, and ArgumentError for a list of labels
not one for each break or limit given; a column of numbers is refused when the plot is run.
Options
:range-{first, last}: the sizes, in millimetres, of the first and last values, each 0 or more; the theme'spalette_size_discrete:, or else 2 to 6, when not given.:na_value- The size, in millimetres, of a missing value, or of one outside the limits, 0 or more; none, which draws nothing, when not given.:name- The legend's or colour bar's title, or:nonefor none; the title its mapping gives when not given.:aesthetics- The aesthetics the scale serves, a list or one alone,:colourspelled:color: one scale trained once over every one of them in this order, each drawing its own guide. A colour or fill scale serves:colorand:fill; an alpha, size or line width scale:alpha,:sizeand:linewidth, every value it gives checked as each takes one; a shape scale:shapeand a line type scale:linetype; an identity scale any of them. The function's own aesthetic alone when not given. A later scale serving any of them replaces this one whole.:limits- The values the scale shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them takesna_value:. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the legend shows a key for, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs, a pair's label its key's; or:nonefor no legend; every one of the limits when not given.:labels- The keys' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor keys with no labels. Each value written as text when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.:guide- What reads the scale back::legend, a key for each break, or{:legend, options}, a legend drawn as its options say ("Guides" inGiggly.Plot), or:nonefor none;guides/2sets one over it. The default value is:legend.iex> plot = ...> %{"wt" => [2.62, 2.32, 3.44], "mpg" => [21.0, 22.8, 18.7], "cyl" => [6, 4, 8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg, size: {:factor, [:cyl], ordered: true}}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_size_ordinal(range: {1, 7}) iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:size) [5.0, 1.0, 7.0]
Gives the plot a binned x scale, replacing any x scale it had.
The x values are cut into bins at the scale's breaks, as scale_color_binned/2 cuts them, and
every value in a bin is placed at the bin's middle, so a bar layer counts each bin and draws a
histogram whose bars stand in their bins: each bar 0.9 of its bin wide, however wide the bin.
Every column on the axis is binned so, a line's intercept and an annotation's place included,
and the stat sees each value as its bin's number, counting from 1 at the lowest, its marks put
back into their bins once it has run. With neither limits: nor breaks:, the limits are the
data's range widened so the end bins are as wide as their neighbours. The axis marks the
breaks, the bins' inner edges, and draws no minor grid lines. The scale's name titles the axis
whatever labs/2 says. Raises NimbleOptions.ValidationError for an option it does not take or
a value it cannot use, and ArgumentError for a list of labels without a list of breaks as
long, or n_breaks: 1 for nice breaks; a column on the axis that is not numbers is refused
when the plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is placed in the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, is not drawn.:squishwhen not given, so a value outside is placed in the bin at the nearer end.:breaks- The values the bins are cut at, which the axis marks, a list of numbers in data units, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer; 1 or more otherwise; or of abreaks:function of two arguments. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number. The default value is10.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether the axis marks the limits too, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"mpg" => [10.4, 15.2, 21.0, 33.9]} ...> |> Giggly.Plot.new(%{x: :mpg}) ...> |> Giggly.Plot.geom_bar() ...> |> Giggly.Plot.scale_x_binned() iex> frame = Giggly.layer_data(plot) iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :xmin)} {[11.25, 16.25, 21.25, 33.75], [10.125, 15.125, 20.125, 32.625]}
Gives the plot a continuous x scale with the given options, replacing any x scale it had.
A value outside the limits is missing, so its mark is not drawn: a point, or a bar counted from
it, and a bar whose ends the limits cut once it is placed. An end at :infinity or
:neg_infinity is kept. oob: says otherwise: :squish moves a value onto the nearer limit,
:keep draws it past the panel's edge, cut off there. The scale's name titles the axis whatever labs/2 says. Raises
ArgumentError for a list of labels without a list of breaks as long; a column on the axis
that is not numbers is refused when the plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.iex> frame = ...> %{"wt" => [1.5, 2.6, 3.4, 5.4], "mpg" => [30.4, 21.0, 18.7, 10.4]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_x_continuous(limits: {2, 5}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [nil, 2.6, 3.4, nil]
The limits may be a function, handed the data's range, that returns them, here taking the axis down to 0 whatever the data:
iex> svg =
...> %{"wt" => [1.5, 2.6, 3.4, 5.4], "mpg" => [30.4, 21.0, 18.7, 10.4]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.scale_x_continuous(limits: fn {low, high} -> {min(low, 0), high} end)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ ">0</text>"
true
Gives the plot a date x scale with the given options, replacing any x scale it had.
A date axis places each date at its days since 1970-01-01 and marks it on calendar boundaries:
every day, week, month or year, as suits its span, or every step of date_breaks:. Its labels
are written as suits the breaks, or in the format date_labels: gives. A value outside the
limits is missing, so its mark is not drawn, unless oob: says otherwise. The scale's name titles the axis whatever labs/2
says. Raises ArgumentError for an option given beside its date_ twin, or a list of labels
without a list of breaks as long; a column on the axis that is not dates is refused when the
plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the dates the axis spans whatever the data,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The dates the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{date, label}pairs, handed the axis's extent,{low, high}, its ends rounded out to whole days, and, taking two arguments,[], such as&Scales.Breaks.pretty/2; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[week: 1]: one of:day,:week,:monthand:yearand how many of it, laid from the widened axis's start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, the breaks the axis chooses are written as suits their step (Sep 21,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %d". Not withlabels:.:minor_breaks- The dates the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> svg = ...> %{"day" => [~D[2026-09-20], ~D[2026-10-19]], "price" => [0.3, 0.8]} ...> |> Giggly.Plot.new(%{x: :day, y: :price}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_x_date(date_breaks: [week: 2], date_labels: "%d %b") ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">28 Sep</text>", svg =~ ">12 Oct</text>"} {true, true}
Gives the plot a date-time x scale with the given options, replacing any x scale it had.
A date-time axis places each DateTime at its seconds since 1970-01-01 00:00 UTC, and each
NaiveDateTime at its seconds since the same time on its own clock, as though it were UTC's;
a column holds one or the other, never both, and so does an axis. It marks them on clock and
calendar boundaries: every few seconds, minutes or hours, every day, week, month or year, as
suits its span, or every step of date_breaks:. Its labels are written as suits the breaks, or
in the format date_labels: gives. Breaks are laid and labels written on the clock of the
axis's time zone, timezone:, else its first column's, naive date-times on their own clock as
though it were UTC's. Where the zone's offset changes, as daylight saving begins or ends, steps
under a day keep their spacing and days, months and years keep their midnight. A zone other
than UTC needs time_zone_database: to name a database that knows it, such as the tz
package's. A value outside the limits is missing, so its mark is not drawn, unless oob: says
otherwise. The scale's name
titles the axis whatever labs/2 says. Raises ArgumentError for an option given beside its
date_ twin, a list of labels without a list of breaks as long, or a time zone the database
does not know; a column on the axis that is not date-times, or is in a zone the database does
not know, or naive beside timezone:, is refused when the plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the date-times the axis spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The date-times the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{date_time, label}pairs, handed the axis's extent,{low, high}, as the column holds date-times, and, taking two arguments,[], such as&Scales.Breaks.pretty/2; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the widened axis's start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of date-times as the column holds them, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, the breaks the axis chooses are written as suits their step (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:minor_breaks- The date-times the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:timezone(String.t/0) - The time zone the axis lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, in seconds, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> svg = ...> %{"at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 23:00:00Z]], "load" => [0.3, 0.8]} ...> |> Giggly.Plot.new(%{x: :at, y: :load}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_x_datetime(date_labels: "%H:%M") ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">06:00</text>", svg =~ ">18:00</text>"} {true, true}
The same day shown in Kolkata's time, five and a half hours ahead:
iex> svg =
...> %{"at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 23:00:00Z]], "load" => [0.3, 0.8]}
...> |> Giggly.Plot.new(%{x: :at, y: :load})
...> |> Giggly.Plot.geom_line()
...> |> Giggly.Plot.scale_x_datetime(
...> timezone: "Asia/Kolkata",
...> time_zone_database: Tz.TimeZoneDatabase
...> )
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ ">Mar 10 12:00</text>", svg =~ ">Mar 11 00:00</text>"}
{true, true}
Gives the plot a discrete x scale with the given options, replacing any x scale it had.
A discrete axis places each value at its own position, 1, 2, 3 and so on, in order: text
alphabetically, numbers by size, the missing value last. limits: chooses which values it shows
and in what order; a value it leaves out is missing, so its mark is not drawn, a point or a bar
counted from it. Each value is named as the column holds it: factor(cyl)'s as 4, 6 and
8, a missing value as nil. The scale's name titles the axis whatever labs/2 says. Raises
ArgumentError for a list of labels not one for each break, or for each limit when no breaks
are given; a column on the axis that is not discrete is refused when the plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits- The values the axis shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them is missing, so its mark is not drawn; one the data lacks leaves its place empty. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the axis marks with a tick and a label, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs; or:nonefor none; every one of the limits when not given.:minor_breaks- The positions the panel draws a minor grid line at, the values placed at 1, 2, 3 and on: a list of numbers; a function that returns them, handed the axis's extent,{low, high}, and, taking two arguments, the breaks' positions; or:nonefor none; none when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break drawn, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs, else each value written as text, when not given.:expand- How far the axis reaches beyond its first and last values,[mult: m, add: a]: at each end, that multiple of the distance between them plus that constant, each a number or{low, high}for the two ends;[add: 0.6]when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.iex> frame = ...> %{"class" => ["suv", "compact", "midsize", "suv"], "hwy" => [17, 29, 26, 20]} ...> |> Giggly.Plot.new(%{x: :class, y: :hwy}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_x_discrete(limits: ["suv", "compact"]) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [1, 2, nil, 1]
Labels given by value:
iex> svg =
...> %{"class" => ["suv", "compact"], "hwy" => [17, 29]}
...> |> Giggly.Plot.new(%{x: :class, y: :hwy})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.scale_x_discrete(labels: %{"suv" => "SUV"})
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ ">SUV</text>", svg =~ ">compact</text>"}
{true, true}
Gives the plot a continuous x scale through a base-10 logarithm, replacing any x scale it had,
as scale_x_continuous(plot, transform: :log10) does: each value is placed at its logarithm,
and the axis marked at powers of ten, or at multiples of them where too few powers fall on it,
and labelled in data units. Zero is placed at minus infinity, the panel's edge, and a negative
value is missing.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [1, 10, 100], "y" => [3, 1, 2]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_x_log10() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x) [0.0, 1.0, 2.0]
Gives the plot a continuous x scale running from high to low, replacing any x scale it had, as
scale_x_continuous(plot, transform: :reverse) does: each value is placed at its negation, and
the axis marked and labelled in data units.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [1.5, 2.5, 3.5], "y" => [3, 1, 2]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_x_reverse() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x) [-1.5, -2.5, -3.5]
Gives the plot a continuous x scale through a square root, replacing any x scale it had, as
scale_x_continuous(plot, transform: :sqrt) does: each value is placed at its square root, and
the axis marked and labelled in data units. A negative value is missing.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [1, 4, 9], "y" => [3, 1, 2]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_x_sqrt() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x) [1.0, 2.0, 3.0]
Gives the plot a time x scale with the given options, replacing any x scale it had.
A time axis places each Time at its seconds since midnight and marks it on round seconds,
minutes or hours, as suits its span, or every step of date_breaks:. Its labels give hours,
minutes and seconds (10:30:00), the hours counting on past midnight where the axis reaches
beyond it (24:00:00), or are written in the format date_labels: gives, wrapped round
midnight. A value outside the limits is missing, so its mark is not drawn, unless oob: says
otherwise. The scale's name
titles the axis whatever labs/2 says. Raises ArgumentError for an option given beside its
date_ twin, or a list of labels without a list of breaks as long; a column on the axis that is
not times is refused when the plot is run.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the times of day the axis spans whatever the data,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The times of day the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{time, label}pairs, handed the axis's extent,{low, high}, as times of day wrapped past midnight, and, taking two arguments,[]; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[minute: 30]: one of:second,:minuteand:hourand how many of it, laid from the widened axis's start, rounded down to a multiple of the step since midnight, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns, a pair's label when it returns pairs; a function handed every break drawn, a list of times of day, wrapped past midnight, so a break at the end of the day is~T[00:00:00], that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, each break is written in hours, minutes and seconds, with as many decimals of a second as the most precise needs, the hours counting on past midnight and a break before it negative (10:30:00,24:00:00,-00:00:30).:date_labels- The format every break's label is written in, asCalendar.strftime/3writes a time of day, such as"%H:%M", a break past midnight wrapped round it, so the end of the day is written as its start. Not withlabels:.:minor_breaks- The times of day the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, in seconds, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> svg = ...> %{"at" => [~T[06:10:00], ~T[21:40:00]], "load" => [0.3, 0.8]} ...> |> Giggly.Plot.new(%{x: :at, y: :load}) ...> |> Giggly.Plot.geom_line() ...> |> Giggly.Plot.scale_x_time() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">06:00:00</text>", svg =~ ">22:00:00</text>"} {true, true}
A break every six hours of a whole day, its last at midnight again:
iex> svg =
...> %{"at" => [~T[00:00:00], ~T[23:59:59]], "load" => [0.3, 0.8]}
...> |> Giggly.Plot.new(%{x: :at, y: :load})
...> |> Giggly.Plot.geom_line()
...> |> Giggly.Plot.scale_x_time(date_breaks: [hour: 6], date_labels: "%H:%M")
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg |> String.split(">00:00</text>") |> length()
3
Gives the plot a binned y scale, replacing any y scale it had, as scale_x_binned/2 gives an x
scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains and cuts its bins in transformed space, finds its breaks and widens its limits in data units, an end the transformation cannot place left at the data's, takes its limits and breaks in data units, and labels its breaks in data units.:limits-{low, high}: the values the bins span whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is placed in the bin at the nearer end, unlessoob:says otherwise. The data's range, widened so the end bins are as wide as their neighbours, when neither this norbreaks:is given. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits before it is binned::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. A value left outside, or left missing, is not drawn.:squishwhen not given, so a value outside is placed in the bin at the nearer end.:breaks- The values the bins are cut at, which the axis marks, a list of numbers in data units, those outside the limits left out; a function that returns them, or{break, label}pairs, handed the limits,{low, high}, and, taking two arguments,[n: n_breaks]; or:nonefor one bin; chosen from the limits asn_breaks:andnice_breaks:say when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break, a list of numbers, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do, and handed the limits too whereshow_limits:shows them; or:nonefor no labels. A pair's label when abreaks:function returns pairs.:n_breaks(pos_integer/0) - How many breaks are wanted whenbreaks:is not given: 2 or more for nice breaks, but under a logarithm, which may number a few more or fewer; 1 or more otherwise; or of abreaks:function of two arguments. When given, not besidebreaks:a list,:noneor a function of one argument, which wants no number. The default value is10.:nice_breaks(boolean/0) - Whether breaks not given are round numbers, chosen as a continuous scale's are, orn_breaks:spaced evenly between the ends of the limits. The default value istrue.:right(boolean/0) - Where a value on a break falls:truein the bin below it,falsein the bin above. The default value istrue.:show_limits(boolean/0) - Whether the axis marks the limits too, unless a break is already there; not beside a list oflabels:, which labels the breaks alone. The default value isfalse.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [1, 2, 3, 4], "y" => [1, 2, 3, 4]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_binned() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y) [1.25, 1.75, 2.75, 3.75]
Gives the plot a continuous y scale with the given options, replacing any y scale it had, as
scale_x_continuous/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.:transform- What each value is put through before the scale sees it, a transformation ofScales.Transform's::identity,:log,:log2,:log10,{:log, base},:log1p,:exp,{:exp, base},:asinh,:pseudo_log,{:pseudo_log, sigma: sigma, base: base},:sqrt,:reverse,:reciprocal,:asn,:atanh,:logit,:probit,{:probability, :normal, mean: mean, sd: sd},{:probability, :logistic, location: location, scale: scale},{:boxcox, exponent},{:boxcox, exponent, offset: offset},{:modulus, exponent},{:modulus, exponent, offset: offset},{:yj, exponent},:timespan,{:timespan, unit}, a composition{:compose, [part, ...]}or oneScales.Transform.new/2makes;:identitywhen not given. The scale trains, breaks and places in transformed space, its limits and breaks given in data units, and labels its breaks in data units.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_continuous(name: "Miles per gallon", breaks: [21, 22]) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ ">Miles per gallon</text>", svg =~ ">21</text>", svg =~ ">22</text>"} {true, true, true}
Gives the plot a date y scale with the given options, replacing any y scale it had, as
scale_x_date/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the dates the axis spans whatever the data,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The dates the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{date, label}pairs, handed the axis's extent,{low, high}, its ends rounded out to whole days, and, taking two arguments,[], such as&Scales.Breaks.pretty/2; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[week: 1]: one of:day,:week,:monthand:yearand how many of it, laid from the widened axis's start, rounded down to a multiple of the days since 1970-01-01, a Monday, the 1st of a month or 1 January, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of dates, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, the breaks the axis chooses are written as suits their step (Sep 21,2026), abreaks:function's pairs by their labels, and others in full (2026-09-21).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%b %d". Not withlabels:.:minor_breaks- The dates the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> frame = ...> %{"price" => [0.3, 0.8, 0.5], "day" => [~D[2026-09-20], ~D[2026-10-19], ~D[2026-10-01]]} ...> |> Giggly.Plot.new(%{x: :price, y: :day}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_date(limits: {~D[2026-10-01], nil}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [nil, 20745.0, 20727.0]
Gives the plot a date-time y scale with the given options, replacing any y scale it had, as
scale_x_datetime/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the date-times the axis spans whatever the data,DateTimes orNaiveDateTimes as its column holds,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The date-times the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{date_time, label}pairs, handed the axis's extent,{low, high}, as the column holds date-times, and, taking two arguments,[], such as&Scales.Breaks.pretty/2; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[hour: 6]: one of:second,:minute,:hour,:day,:week,:monthand:yearand how many of it, laid from the widened axis's start, rounded to the nearest multiple of the step since 1970-01-01 for seconds and minutes, else down to the start of its hour, its day, the Monday of its week, the 1st of its month or 1 January, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of date-times as the column holds them, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, the breaks the axis chooses are written as suits their step (06:00,Mar 10 06:00,Mar 10), abreaks:function's pairs by their labels, and others in full, the date alone where every one is a midnight (2024-03-10), else to the second (2024-03-10 06:30:00).:date_labels- The format every break's label is written in, asCalendar.strftime/3takes it, such as"%H:%M". Not withlabels:.:minor_breaks- The date-times the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:timezone(String.t/0) - The time zone the axis lays its breaks and writes its labels in, such as"America/New_York", whichtime_zone_database:must know; the first date-time column's when not given. Naive date-times are in no time zone, so a column of them is refused beside it.:time_zone_database(atom/0) - The time zone database that reads the axis's time zone, a module implementingCalendar.TimeZoneDatabase, such as the tz package'sTz.TimeZoneDatabase;Calendar.UTCOnlyTimeZoneDatabase, which knows UTC alone, when not given, never the one the application configures.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, in seconds, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> frame = ...> %{"load" => [0.3, 0.8], "at" => [~U[2024-03-10 00:00:00Z], ~U[2024-03-10 12:00:00Z]]} ...> |> Giggly.Plot.new(%{x: :load, y: :at}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_datetime(limits: {~U[2024-03-10 06:00:00Z], nil}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [nil, 1710072000.0]
Gives the plot a discrete y scale with the given options, replacing any y scale it had, as
scale_x_discrete/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits- The values the axis shows, a list in the order shown, whatever the data; each value as the column holds it,nilfor the missing value, a number naming the value equal to it. A value not among them is missing, so its mark is not drawn; one the data lacks leaves its place empty. Every value the data holds, in order, when not given. Or a function of one argument, handed the values the data holds, in order, that returns them.:breaks- The values the axis marks with a tick and a label, a list in the order given, those not among the limits left out; a function of one argument handed the limits that returns them, or{value, label}pairs; or:nonefor none; every one of the limits when not given.:minor_breaks- The positions the panel draws a minor grid line at, the values placed at 1, 2, 3 and on: a list of numbers; a function that returns them, handed the axis's extent,{low, high}, and, taking two arguments, the breaks' positions; or:nonefor none; none when not given.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each break, or for each limit when no breaks are given; a map from a value to its label, a value it does not hold keeping its own; a function handed every break drawn, a list of values, that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs, else each value written as text, when not given.:expand- How far the axis reaches beyond its first and last values,[mult: m, add: a]: at each end, that multiple of the distance between them plus that constant, each a number or{low, high}for the two ends;[add: 0.6]when not given.:drop(boolean/0) - Whether a factor's levels no value holds are left out (true), or kept (false), each taking its place as if a value held it, the missing value after them where one is missing. A column with no levels of its own has none to keep. The default value istrue.:na_translate(boolean/0) - Whether the missing value is one of the values (true), or is left out (false), so it, and a value outsidelimits:, maps to nothing and is not drawn;na_value:is refused besidefalse. The default value istrue.iex> frame = ...> %{"hwy" => [17, 29, 26], "class" => ["suv", "compact", "midsize"]} ...> |> Giggly.Plot.new(%{x: :hwy, y: :class}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_discrete(limits: ["suv", "midsize", "compact"]) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [1, 3, 2]
Gives the plot a continuous y scale through a base-10 logarithm, replacing any y scale it had,
as scale_x_log10/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [3, 1, 2], "y" => [1, 10, 100]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_log10() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y) [0.0, 1.0, 2.0]
Gives the plot a continuous y scale running from high to low, replacing any y scale it had, as
scale_x_reverse/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [3, 1, 2], "y" => [1.5, 2.5, 3.5]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_reverse() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y) [-1.5, -2.5, -3.5]
Gives the plot a continuous y scale through a square root, replacing any y scale it had, as
scale_x_sqrt/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the values the axis spans whatever the data, in data units,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The values the axis marks with a tick, a label and a grid line, a list of numbers in data units; a function that returns them, or{break, label}pairs, handed the axis's extent in data units,{low, high}, and, taking two arguments,[n: n]asn_breaks:asks,[]when not given, such as&Scales.Breaks.extended/2; or:nonefor none; chosen from the limits when not given. A break is drawn wherever it falls inside the widened axis.:minor_breaks- The values the panel draws a minor grid line at, a list of numbers in data units; a function that returns them, handed the axis's extent in data units,{low, high}, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks, once transformed, when not given.:n_breaks(pos_integer/0) - How many breaks are wanted, of the breaks chosen whenbreaks:is not given, 2 or more but on a log axis, or of abreaks:function of two arguments; not besidebreaks:a list,:noneor a function of one argument, which wants no number.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns; a function handed every break drawn, a list of numbers in data units, that returns a label for each, a string, a power, a label another library lays out ornil, asScales.Labels's do; or:nonefor ticks with no labels. A pair's label when abreaks:function returns pairs.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> plot = ...> %{"x" => [3, 1, 2], "y" => [1, 4, 9]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_sqrt() iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y) [1.0, 2.0, 3.0]
Gives the plot a time y scale with the given options, replacing any y scale it had, as
scale_x_time/2 gives an x scale.
Options
:name- The axis's title, or:nonefor none; the title its mapping gives when not given.:guide- What reads the axis back::axis, ticks and labels beside the panel;{:axis, options}, one drawn as its options say;:axis_logticksor{:axis_logticks, options}, one with logarithmic ticks;:axis_stackor{:axis_stack, options}, several axes one beyond the other; round a radial panel's circle,:axis_thetaor{:axis_theta, options}, the angle axis, or a stack of them ("Guides" inGiggly.Plot); or:nonefor none, its title kept; round a radial panel's circle the angle axis when not given;guides/2sets one over it.:position- The side of the panels the axis goes on, its title with it::bottomor:topfor an x scale,:leftor:rightfor a y scale;:bottomor:leftwhen not given. An axis's guide giving aposition:moves both over it. Undercoord_radial/2, the radius's scale's:rightor:topputs the radius axis right of the panel, and the angle's scale's:topor:rightthe angle's title above it.:sec_axis- A secondary axis, drawn opposite the axis: a function of one value, which turns each of the axis's values into the secondary axis's; a keyword list of its options ("Secondary axes" inGiggly.Plot), each its own unless given:derive, the axis's;:duplicate, a copy of the axis with every option the axis's, its title included; or{:duplicate, options}, a copy with those options its own.guides/2'sx_sec:ory_sec:sets its guide over its own.:limits-{low, high}: the times of day the axis spans whatever the data,nilfor an end the data decides; either order names the same axis. A value outside them is missing, so its mark is not drawn, unlessoob:says otherwise. Or a function of one argument, handed the data's range in data units,{low, high}, or{:infinity, :neg_infinity}where it holds no finite value, that returns the limits, kept in the order returned.:oob- What happens to a value outside the limits::censor, a finite number outside made missing;:censor_any, an infinity too;:squish, a finite number moved onto the nearer limit;:squish_any, an infinity too;:squish_infinite, an infinity alone moved onto its limit;:keep, every value kept; or a function handed the values and the limits,{low, high}, both transformed, that returns a value for each, a number, an infinity,nilor:nan. Run on the positions as given and again once the stat and position have moved them, so a bar whose base the limits leave out is missing; a value kept outside is drawn past the panel's edge and cut off there.:censorwhen not given.:breaks- The times of day the axis marks with a tick, a label and a grid line, a list; a function that returns them, or{time, label}pairs, handed the axis's extent,{low, high}, as times of day wrapped past midnight, and, taking two arguments,[]; or:nonefor none; chosen from the limits when neither this nordate_breaks:is given. A break is drawn wherever it falls inside the widened axis.:date_breaks- A break every step,[minute: 30]: one of:second,:minuteand:hourand how many of it, laid from the widened axis's start, rounded down to a multiple of the step since midnight, to its end. Not withbreaks:.:labels- The breaks' labels: a list of strings or labels another library lays out (Giggly.Label),nildrawnNA, one for each ofbreaks:, or of the breaks its function returns, a pair's label when it returns pairs; a function handed every break drawn, a list of times of day, wrapped past midnight, so a break at the end of the day is~T[00:00:00], that returns a label for each, a string, a power, a label another library lays out ornil; or:nonefor ticks with no labels. Not withdate_labels:. When neither is given, each break is written in hours, minutes and seconds, with as many decimals of a second as the most precise needs, the hours counting on past midnight and a break before it negative (10:30:00,24:00:00,-00:00:30).:date_labels- The format every break's label is written in, asCalendar.strftime/3writes a time of day, such as"%H:%M", a break past midnight wrapped round it, so the end of the day is written as its start. Not withlabels:.:minor_breaks- The times of day the panel draws a minor grid line at, a list; a function that returns them, handed the axis's extent asbreaks:'s is, and, taking two arguments, the breaks drawn; or:nonefor none; midway between the breaks when neither this nordate_minor_breaks:is given.:date_minor_breaks- A minor grid line every step, asdate_breaks:lays breaks. Not withminor_breaks:.:expand- How far the axis reaches beyond its limits,[mult: m, add: a]: at each end, that multiple of the limits' width plus that constant, in seconds, each a number or{low, high}for the two ends;[mult: 0.05]when not given.iex> frame = ...> %{"load" => [0.3, 0.8], "at" => [~T[05:00:00], ~T[12:00:00]]} ...> |> Giggly.Plot.new(%{x: :load, y: :at}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.scale_y_time(limits: {~T[06:00:00], nil}) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [nil, 43200.0]
@spec stat_bin(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_histogram/3 adds, bars counting the rows in each bin, from the same mapping
and options, but that a glyph its legend's keys borrow draws its own corners, where
geom_histogram/3's draws pointed ones.
iex> plot =
...> %{"x" => [1.0, 1.5, 2.5, 4.0]}
...> |> Giggly.Plot.new(%{x: :x})
...> |> Giggly.Plot.stat_bin(binwidth: 1, boundary: 0)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:density)
[0.5, 0.25, 0.25]
@spec stat_bin_2d(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_bin_2d/3 adds, tiles counting the rows in each rectangle, from the same
mapping and options, but that a glyph its legend's keys borrow draws its own corners, where
geom_bin_2d/3's draws pointed ones.
iex> frame =
...> %{"x" => [1.0, 1.2, 2.5, 3.0, 4.0], "y" => [1.0, 1.1, 2.0, 3.5, 4.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.stat_bin_2d(binwidth: 1)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :density)
[0.4, 0.2, 0.2, 0.2]
@spec stat_bin_hex(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_hex/3 adds, hexagons counting the rows in each, from the same mapping and
options, but that linejoin: takes no default: the hexagons' corners are pointed, and a
legend's keys draw their glyph's own unless it is given.
iex> frame =
...> %{"x" => [0.0, 0.1, 1.0, 2.0], "y" => [0.0, 0.1, 1.0, 2.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.stat_bin_hex(binwidth: 1)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :density)
[0.5, 0.25, 0.25]
@spec stat_connect(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of connections: for each group, its rows in order of x, each joined to the next
by a path of the shape connection: gives, so a series can be drawn as steps, as steps
halfway between its rows, or by any shape of one's own. The default steps across to the next
row's x and then up to its y, as a quantity that holds until it changes is drawn.
A connection layer uses :x, :xmin, :xmax, :y, :ymin, :ymax and :group, and needs
one of :x, :xmin and :xmax and one of :y, :ymin and :ymax; its geom draws with the
aesthetics its own function takes, and needs what it needs, as geom_path/3 draws a line
through :x and :y unless geom: says otherwise. Each place a connection passes through
stretches every position column the layer gives between the two rows, so a ribbon's ymin and
ymax step together; every other column is the earlier row's, so a colour that varies changes
where a step leaves its row. Rows given an xmin or xmax and neither ymin nor ymax are
connected along y, in order of y. A row missing or infinite in any position column is left
out, and a group of fewer than two rows is drawn without a connection. A mapping's after_stat
reads nothing the layer computes.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:path, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:path.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:connection- How each row is joined to the next: across and then up (:hv), up and then across (:vh), halfway across, up and on (:mid), straight (:linear), or a list of{x, y}points, each two finite numbers, on a path from{0, 0}at the one row to{1, 1}at the next, stretched between them; a list of none draws the rows as they come. The default value is:hv.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given.
Raises NimbleOptions.ValidationError for an option the geom does not take, or a value it
cannot use.
iex> frame =
...> [x: [3, 1, 2], y: [30, 10, 20]]
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.stat_connect()
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :x)
[1.0, 2.0, 2.0, 3.0, 3.0]
iex> Giggly.DataFrame.pull(frame, :y)
[10.0, 10.0, 20.0, 20.0, 30.0]
@spec stat_contour(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_contour/3 adds, contour lines through :z over a grid of :x and :y,
from the same mapping and options, but that linejoin: takes no default: the lines' corners
are rounded, and a legend's keys draw their glyph's own unless it is given.
iex> frame =
...> %{"x" => [1.0, 2.0, 1.0, 2.0], "y" => [1.0, 1.0, 2.0, 2.0], "z" => [0.0, 1.0, 1.0, 2.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z})
...> |> Giggly.Plot.stat_contour(breaks: [0.5, 1.5])
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :level)
[0.5, 0.5, 1.5, 1.5]
@spec stat_contour_filled(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_contour_filled/3 adds, contour bands through :z over a grid of :x and
:y, from the same mapping and options, but that linejoin: takes no default: the bands'
corners are rounded, and a legend's keys draw their glyph's own unless it is given, pointed for
a band's own.
iex> frame =
...> %{"x" => [1.0, 2.0, 1.0, 2.0], "y" => [1.0, 1.0, 2.0, 2.0], "z" => [0.0, 1.0, 1.0, 2.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z})
...> |> Giggly.Plot.stat_contour_filled(breaks: [0, 2])
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.row_count(frame)
5
iex> Giggly.DataFrame.pull(frame, :level) |> Enum.uniq()
["(0, 2]"]
@spec stat_density(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of densities, each the same estimate geom_density/3 makes, drawn as areas
(geom_area/3): filled with the theme's ink mixed 20% toward its paper and unoutlined unless a
colour is mapped or set, and piled on one another unless position: :identity draws each where
it is. It takes geom_density/3's options, and computes and refuses what it does.
Given another geom in geom:, the densities are drawn with it, as its own function draws them
and with its options in place of the area's, still piled on one another unless position:
says otherwise: geom: :point draws a point at each place, geom: :line a line through them.
A geom whose marks take no piling, such as :boxplot, needs a position: they take, and one
drawn from what a density does not compute, such as a text's :label, refuses the layer.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:area, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:area.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:stack.:outline_type- Which of each band's edges its outline draws: the upper and the lower, each a line (:both), the upper alone (:upper), the lower alone (:lower), or the band's whole border (:full). The default value is:both.:bw- How smooth each curve is, its bandwidth, the kernel's standard deviation in the axis's transformed units: a number above 0, or a rule worked out from each group's rows, taking no weight: Silverman's rule of thumb (:nrd0), 0.9 times the lesser of the rows' standard deviation and their interquartile range over 1.34, times the rows to the power -0.2, or Scott's variation of it (:nrd), 1.06 times the lesser. The default value is:nrd0.:adjust- A multiple of the bandwidth, above 0:adjust: 0.5halves it, for a curve that follows the rows more closely, andadjust: 2doubles it, for a smoother one. The default value is1.0.:kernel- The shape put at each row and summed, scaled so its standard deviation is the bandwidth: a normal curve (:gaussian), a parabola (:epanechnikov), a block (:rectangular), a tent (:triangular), a parabola squared (:biweight), or a cosine's hump (:cosine) or a narrower one (:optcosine). The default value is:gaussian.:n(pos_integer/0) - How many evenly spaced places each curve is worked out at, twice as many with one finite bound and three times with two. The default value is512.:trim(boolean/0) - Whether each curve spans only its own group's extent rather than the panel's axis, short of its widening; trimmed curves no longer share their places, so they do not stack. The default value isfalse.:bounds- Limits the rows are known to lie within,{low, high}, the low a number or:neg_infinity, the high a number or:infinity, not below the low: the rows outside them are left out, and each curve's part beyond a finite one is folded back inside it, so the curve does not spill past a limit the data cannot. The default value is{:neg_infinity, :infinity}.:orientation- The axis the layer runs along,:xor:y, which must be the one of:xand:ymapped; it runs along that one when this is not given.:alpha- How opaque every band's fill is, from 0, invisible, to 1, opaque; its outline keeps its colour's own alpha.:color- The colour of every band's outline, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no outline when not given.:fill- The colour every band is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every band's outline is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every band's outline::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 4.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.stat_density(n: 2) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [1.0, 4.0]
The same densities drawn as points:
iex> plot =
...> %{"x" => [1.0, 2.0, 4.0, 4.0]}
...> |> Giggly.Plot.new(%{x: :x})
...> |> Giggly.Plot.stat_density(geom: :point, n: 2)
iex> [%Giggly.Plot.Layer{geom: geom}] = plot.reversed_layers
iex> geom.__struct__
Giggly.Geom.Point
@spec stat_density_2d(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_density_2d/3 adds, a two-dimensional density of :x and :y, drawn with
its contour lines unless geom: names another geom, most often with contour: false, a mark
at each point of the grid: :point points, :raster a raster's cells, :tile tiles. A geom
given with contouring left on draws the contour lines' points.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:density_2d, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:density_2d.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:contour_var- Which of the grid's columns is contoured::density,:ndensity, the density over its group's highest, or:count, the density times its group's rows. The default value is:density.:h- The bandwidth along each axis, a number above 0 for both or{across, up}, in the axes' units; MASS'sbandwidth.nrd()of each group's rows, timesadjust:, when not given.:adjust- How many times the rule's bandwidth each axis's is, a number above 0 for both or{across, up}; it does not changeh:. The default value is1.0.:n- How many grid points the density is estimated at along each axis, a whole number above 0 for both or{across, up}. The default value is100.:bins(pos_integer/0) - How many contour breaks there are, evenly spaced over the range of the contoured column, which takes the place ofbinwidth:.:binwidth- How far apart the contour breaks are, a number above 0 in the contoured column's units; a tenth of its range when a breaks function is given alone.:breaks- The contour breaks: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of the contoured column's range,{low, high}, and a bin width, returning the breaks; R'spretty()of the range, about ten, when none of them is given.:contour(boolean/0) - Whether the grid is contoured:truedraws its contour lines,falsethe grid itself, a row at each of its points. The default value istrue.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given.
iex> frame =
...> GigDatasets.faithful()
...> |> Giggly.Plot.new(%{x: :eruptions, y: :waiting})
...> |> Giggly.Plot.stat_density_2d(%{fill: {:after_stat, [:density]}},
...> geom: :raster,
...> contour: false,
...> n: 10
...> )
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.row_count(frame)
100
@spec stat_density_2d_filled(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_density_2d_filled/3 adds, a two-dimensional density's contour bands, from
the same mapping and options, drawn with polygons unless geom: names another geom, which
takes the options of its own function. Its position: is :identity unless given.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:density_2d_filled, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:density_2d_filled.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:contour_var- Which of the grid's columns is contoured::density,:ndensity, the density over its group's highest, or:count, the density times its group's rows. The default value is:density.:h- The bandwidth along each axis, a number above 0 for both or{across, up}, in the axes' units; MASS'sbandwidth.nrd()of each group's rows, timesadjust:, when not given.:adjust- How many times the rule's bandwidth each axis's is, a number above 0 for both or{across, up}; it does not changeh:. The default value is1.0.:n- How many grid points the density is estimated at along each axis, a whole number above 0 for both or{across, up}. The default value is100.:bins(pos_integer/0) - How many contour breaks there are, evenly spaced over the range of the contoured column, which takes the place ofbinwidth:.:binwidth- How far apart the contour breaks are, a number above 0 in the contoured column's units; a tenth of its range when a breaks function is given alone.:breaks- The contour breaks: a list of numbers, which takes the place ofbins:andbinwidth:; or a function of the contoured column's range,{low, high}, and a bin width, returning the breaks; R'spretty()of the range, about ten, when none of them is given.:alpha- How opaque every shape's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every shape's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every shape is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, each band is filled by its level, through the fill scale.:linewidth- How wide every shape's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every shape's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:rule- How a shape of several rings, each asubgroup, is filled::evenoddleaves out what an even number of its rings surround, so a ring inside another is a hole;:windingfills whatever its rings wind round. The default value is:evenodd.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> GigDatasets.faithful() ...> |> Giggly.Plot.new(%{x: :eruptions, y: :waiting}) ...> |> Giggly.Plot.stat_density_2d_filled(n: 20, breaks: [0, 0.01, 0.02]) ...> |> Giggly.layer_data() iex> frame |> Giggly.DataFrame.pull(:level_mid) |> Enum.uniq() [0.005, 0.015]
@spec stat_ecdf(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of empirical cumulative distributions: for each group, the share of its rows at or
below each value of x, drawn as steps (geom_step/3) that climb from 0 to 1, rising at each
value by its rows' share, so the whole distribution is read without binning or smoothing it.
Where a :weight is mapped, the share is of the group's weights, each row counting by its own.
Each group's shares are worked out at its distinct values, unless n: spaces that many evenly
from its least to its greatest, and the steps begin at minus infinity and end at infinity, so
they reach the panel's edges, unless pad: false. The layer's table keeps the distinct values in
the order the rows first give them, as the steps put them in order when drawn.
A layer of ECDFs uses :x or :y, :weight and :group, and needs one of :x and :y: it
runs along x, its shares going up the panel, or along y where :y alone is mapped, its
shares across. A mapped :y beside :x is replaced by the shares. The steps take :alpha,
:color, :linetype and :linewidth, drawn as geom_step/3 draws them, in the theme's ink
unless a colour is mapped or set. A row missing its position, or at an infinite one, is left
out; a weight missing or infinite counts 0, and a negative one counts as it is. A :weight
column must hold numbers. A panel where some group's weights add up to 0 is drawn nothing.
The layer computes each place's ecdf, its share, which a mapping reads with an after_stat
(Giggly.Mapping): %{x: :hwy, color: {:after_stat, [:ecdf]}} colours each step by its share.
The axis the shares go along is titled ecdf unless something else is mapped there.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:step, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:step.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:n(non_neg_integer/0) - How many evenly spaced places each group's share is worked out at, from its least value to its greatest, none for 0, leaving only the padding; when not given, at each of its distinct values.:pad(boolean/0) - Whether each group's steps begin at minus infinity, at a share of 0, and end at infinity, at a share of 1, so they reach the panel's edges. The default value istrue.:direction- How the stairs run from each row to the next: across and then up (:hv), up and then across (:vh), or changing halfway between them (:mid), along y as along x. The default value is:hv.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [3.0, 1.0, 2.0, 2.0, 5.0]} ...> |> Giggly.Plot.new(%{x: :x}) ...> |> Giggly.Plot.stat_ecdf() ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :x) [:neg_infinity, 3.0, 1.0, 2.0, 5.0, :infinity] iex> Giggly.DataFrame.pull(frame, :ecdf) [0.0, 0.8, 0.2, 0.6, 1.0, 1.0]
@spec stat_ellipse(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of data ellipses: for each group, the outline of the ellipse a distribution
fitted to its x and y expects to hold level: of its points, so its centre shows where the
group sits, its size how widely it spreads, and its tilt how x and y move together. The
fit is a multivariate t distribution of 5 degrees of freedom unless type: says otherwise,
which outlying points pull on less than on a normal one, and each outline runs segments:
even steps around its centre, its first place repeated last.
An ellipse layer uses :x, :y, :group and :weight, and needs :x and :y; its geom
draws with the aesthetics its own function takes, as geom_path/3 draws a line unless geom: :polygon fills each ellipse. A row missing its x or y, or at an infinite one, is left out.
Each weight, which must be a number, counts as its share of its group's total; where a share is
missing, NaN, infinite or below 0, or a group's points leave its shape without width, as when
every x is one value, the fit fails and the whole panel is drawn without ellipses. A group of
fewer than four points is given one row of missing values, and a normal fit whose weights are
all one point's an outline of missing values; neither is drawn. A mapping's after_stat reads
nothing the layer computes.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:path, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:path.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:type- The distribution fitted to each group'sxandy: a multivariate t distribution (:t), which outlying points pull on less; a normal one (:norm), from the weighted mean and covariance; or a circle around the weighted mean (:euclid), its radiuslevel:. The default value is:t.:level- The share of the fitted distribution each ellipse holds, above 0 and below 1, for:tand:norm; for:euclidthe circle's radius, a number above 0, in data units. The default value is0.95.:segments(pos_integer/0) - How many even steps each outline is drawn in around its centre, a whole number above 0; the outline has one place more, its first repeated last. The default value is51.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:arrow- An arrowhead on each line:truefor the defaults, or a keyword list of its options,angle:(30),length:({0.25, :in}, in:pt,:cm,:mmor:in),ends:(:last,:firstor:both),type:(:openor:closed) andfill:, a closed head's, a colour,:none, or:color, the line's colour and the default; none when not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given.
Raises ArgumentError for a level: of 1 or more but for :euclid, and when the plot is run
for a weight that is not a number; NimbleOptions.ValidationError for an option the geom does
not take, or a value it cannot use.
iex> frame =
...> GigDatasets.faithful()
...> |> Giggly.Plot.new(%{x: :waiting, y: :eruptions})
...> |> Giggly.Plot.stat_ellipse()
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.row_count(frame)
52
iex> xs = Giggly.DataFrame.pull(frame, :x)
iex> xs |> Enum.take(3) |> Enum.map(fn x -> Float.round(x, 2) end)
[103.45, 103.21, 102.5]
@spec stat_function(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_function/3 adds, a function of x, from the same mapping and options.
iex> frame =
...> Giggly.Plot.new()
...> |> Giggly.Plot.stat_function(fun: fn x -> 2 * x end, n: 3, xlim: {-1, 1}, geom: :point)
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :y)
[-2.0, 0.0, 2.0]
@spec stat_identity(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer drawing a table's rows as they are, its stat the identity, ggplot2's
stat_identity(): points unless geom: names another geom, which takes the options of its own
function. It is the layer every geom function whose stat is the identity adds, drawn with the geom
geom: names.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:point, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:point.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Its position: is :identity unless given.
iex> frame =
...> %{"x" => [1.0, 2.0], "y" => [3.0, 4.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.stat_identity(geom: :line, colour: "red")
...> |> Giggly.layer_data()
iex> Giggly.DataFrame.pull(frame, :color)
["#FF0000", "#FF0000"]
@spec stat_manual(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer computed by a function of your own: for each group in each panel, fun: is handed
the group's rows and returns the rows to draw, so any computation a layer needs, a convex hull,
each group's centre, a line from each point to it, is a function away. It draws points unless
geom: names another geom; stat: :manual gives any geom function the same stat, with its
fun:.
The function is handed a map of the group's columns, each a list keyed by its aesthetic, :x,
:y, :color and the rest the layer maps, and :panel and :group, with the positions as the
scales have mapped them, so a value on a log10 axis is its logarithm and a discrete value its
level's place, counting from 1. It returns a map of the same shape: every column a list, all of
one length, an aesthetic's other spelling taken (:colour), and a name that is no aesthetic's a
column a mapping's after_stat reads; a map of no columns draws the group nothing. Each column
it leaves out that holds one value throughout every group is kept, a colour mapped by group
among them, so a function returning only :x and :y keeps its group's colour. Its arguments
are its closure's.
What the geom needs is checked once the function has run, against what it returned, an option
setting it, or a mapping's after_stat: segments drawn this way need the function to return an
:xend or a :yend. A function returning anything but such a map raises ArgumentError
naming what it returned, and an error raised in it reaches the caller.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:point, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:point.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:fun(function of arity 1) - The function each group's rows are computed by: handed them as a map of columns, each a list keyed by its aesthetic,%{x: [...], y: [...], group: [...]}, with the positions as the scales have mapped them, it returns the rows to draw as a map of the same shape, every column a list of one length; a name that is no aesthetic's is a column a mapping's after_stat reads. Its arguments are its closure's. When not given, the rows are drawn as they are. The default value is&Function.identity/1.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given.
iex> centre = fn rows ->
...> %{x: [Enum.sum(rows.x) / length(rows.x)], y: [Enum.sum(rows.y) / length(rows.y)]}
...> end
iex> frame =
...> %{"x" => [1.0, 3.0, 10.0, 20.0], "y" => [2.0, 4.0, 1.0, 3.0], "g" => ~w(a a b b)}
...> |> Giggly.Plot.new(%{x: :x, y: :y, colour: :g})
...> |> Giggly.Plot.stat_manual(fun: centre, size: 4)
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)}
{[2.0, 15.0], [3.0, 2.0]}
@spec stat_qq(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_qq/3 adds, quantile-quantile points, from the same mapping and options.
iex> frame =
...> %{"s" => [3.0, 1.0, 2.0]}
...> |> Giggly.Plot.new(%{sample: :s})
...> |> Giggly.Plot.stat_qq(distribution: {:normal, mean: 10, sd: 2})
...> |> Giggly.layer_data()
iex> frame |> Giggly.DataFrame.pull(:x) |> Enum.map(fn x -> Float.round(x, 6) end)
[8.261152, 10.0, 11.738848]
@spec stat_qq_line(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_qq_line/3 adds, quantile-quantile lines, from the same mapping and
options.
iex> frame =
...> %{"s" => [2.1, -0.5, 0.3, 1.7, -1.2]}
...> |> Giggly.Plot.new(%{sample: :s})
...> |> Giggly.Plot.stat_qq_line(line_p: {0.1, 0.9})
...> |> Giggly.layer_data()
iex> frame |> Giggly.DataFrame.pull(:intercept) |> Enum.map(fn x -> Float.round(x, 6) end)
[0.51, 0.51]
@spec stat_quantile(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_quantile/3 adds, quantile lines of :y along :x, from the same mapping
and options, but that linejoin: takes no default: the lines' corners are rounded, and a
legend's keys draw their glyph's own unless it is given.
iex> frame =
...> %{"x" => [1.0, 2.0, 3.0, 4.0], "y" => [1.0, 3.0, 2.0, 4.0]}
...> |> Giggly.Plot.new(%{x: :x, y: :y})
...> |> Giggly.Plot.stat_quantile(quantiles: [0.25, 0.75])
...> |> Giggly.layer_data()
iex> frame |> Giggly.DataFrame.pull(:quantile) |> Enum.uniq()
[0.25, 0.75]
@spec stat_smooth(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of smooths, as geom_smooth/3 does: the same curves, options and refusals.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:smooth, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:smooth.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:method- How each curve is fitted::lm, a straight line by least squares;:loess, at each place a quadratic fitted to the nearest rows, nearer ones weighing more; or:gam, a smoothing spline, its wiggliness chosen from the rows; each row weighted too by its:weightwhere one is mapped. When not given, loess where the largest group in any panel holds under 1,000 rows, and gam from there.:se(boolean/0) - Whether each curve is drawn over its band, the confidence interval around it atlevel:. The default value istrue.:level- How confident each band is, above 0 and below 1. The default value is0.95.:n(pos_integer/0) - How many evenly spaced places along x each curve is worked out at. The default value is80.:span- How much of a group each loess fit reads, above 0: the share of its rows nearest each place, so a smaller span follows the rows more closely; only loess reads it. The default value is0.75.:fullrange(boolean/0) - Whether each curve spans the panel's axis it runs along, short of its widening, rather than its own group's extent along it. The default value isfalse.:orientation- The axis each curve runs along::x, y fitted to x, or:y, x fitted to y, for a curve that runs up the panel. The default value is:x.:alpha- How opaque every band's fill is, from 0, invisible, to 1, opaque; 0.4 when not given. The line keeps its colour's own alpha.:color- The colour of every curve's line, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's accent,#3366FF, when not given.:fill- The colour every band is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 60% toward its paper,#999999, or#00000066undertheme_void/2, whose paper is clear.:linewidth- How wide every curve's line is, in millimetres; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a line turns a corner: rounded (:round), pointed (:mitre) or cut off (:bevel); when not given, rounded, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 2.0, 3.0, 4.0], "y" => [1.0, 3.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y}) ...> |> Giggly.Plot.stat_smooth(method: :lm, n: 2) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :y) [1.2999999999999998, 3.7]
@spec stat_sum(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds the layer geom_count/3 adds, points counting the rows at each place, from the same
mapping and options.
iex> plot =
...> %{"cty" => [18, 18, 21], "hwy" => [29, 29, 29]}
...> |> Giggly.Plot.new(%{x: :cty, y: :hwy})
...> |> Giggly.Plot.stat_sum()
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:prop)
[0.6666666666666666, 0.3333333333333333]
@spec stat_summary(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer summarising the y values at each x: for each group, a row at each of its x
positions, its y a summary of the values there and its ymin and ymax an interval round
it, drawn as point ranges unless geom: says otherwise. Given no summary, it is the mean less
and plus one standard error, which a position holding one value has no interval for. A row
missing its x or y, or at an infinite one, is left out.
fun_data: gives the whole summary by name, alone or in a tuple with its arguments; fun:,
fun_min: and fun_max: give its y, ymin and ymax one at a time, by name or as a
function of the values, and one not given is missing, so fun: :mean alone draws points with no
ranges. A bootstrap's resamples are drawn from its seed:, each position's afresh, so a plot
draws the same intervals every time it is drawn, and another seed draws others.
Where y alone is discrete, the x values are summarised at each y instead, into x,
xmin and xmax, and the marks run across the panel; orientation: says which way.
A summary uses :x, :y and :group and the aesthetics its geom draws with, and needs :x and
:y; it writes the range, so :ymin, :ymax, :xmin and :xmax are not mapped. Every other
aesthetic goes to the summary at each position where it holds one value among that position's
rows, and is missing where it holds more, so a discrete one groups the rows and gives each
group its own summaries.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:pointrange, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:pointrange.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:fun_data- The whole summary at each position, itsy,yminandymax, by name, alone or in a tuple with its arguments,{:mean_sdl, mult: 1}::mean_se, the mean less and plusmult:standard errors (1);:mean_cl_normal, the mean and its confidence interval atconf_int:(0.95, from 0, below 1) from the t distribution, ormult:standard errors in place of the t;:mean_sdl, the mean less and plusmult:standard deviations (2);:median_hilow, the median and the quantiles holdingconf_int:(0.95, 0 to 1) of the values between them, as many either side; and:mean_cl_boot, the mean and its bootstrap interval atconf_int:(0.95, 0 to 1), fromresamples:(1000) resamples drawn fromseed:(0), any integer. Amult:is any number. Refused besidefun:,fun_min:orfun_max:;:mean_sewhen none of them is given.:fun- The summary'syat each position::mean,:median,:minor:max, or a function given the values there, a list of numbers in their rows' order, returning a number. Missing when not given besidefun_min:orfun_max:.:fun_min- The summary'syminat each position, asfun:gives itsy.:fun_max- The summary'symaxat each position, asfun:gives itsy.:orientation- Which way the summary runs::x, theyvalues summarised at eachx, or:y, thexvalues at eachy; when not given,:ywhereyalone is discrete, and:xotherwise.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:color- The colour of every line and point, writtencolour:orcolor:, which outlines the point's shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres, each drawn four times as big; a third of the theme's points' size when not given, 0.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function but orientation:, which is the summary's and
which the geom follows: :point those of geom_point/3, :line of geom_line/3, :bar of
geom_bar/3, :crossbar of geom_crossbar/3, :errorbar of geom_errorbar/3, :ribbon of
geom_ribbon/3, and any other. Its position: is :identity unless given, the bars'
included, and dodging's orientation: is refused, the summary's overriding it.
Raises ArgumentError for fun_data: beside fun:, fun_min: or fun_max:;
NimbleOptions.ValidationError for an option the geom does not take, or a value it cannot use.
iex> frame =
...> %{"cyl" => [4, 4, 6, 6], "mpg" => [22.0, 26.0, 18.0, 20.0]}
...> |> Giggly.Plot.new(%{x: :cyl, y: :mpg})
...> |> Giggly.Plot.stat_summary()
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :y), Giggly.DataFrame.pull(frame, :ymin)}
{[24.0, 19.0], [22.0, 18.0]}
@spec stat_summary_2d(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of rectangles each summarising a third variable, :z, over the rows in it: the
plane cut into rectangles along x and y, as geom_bin_2d/3 cuts it, and for each group a
tile wherever a row falls, filled by the mean of the z of its rows, or the summary fun:
gives. A heatmap of how a value varies over two others.
A row missing its x, y or z, or at an infinite one, is left out. The bins meet at 0
unless boundary: places them; center: is refused, since ggplot2's 4.0.3 starts these bins
on a boundary of 0 whatever it is given and so fails to place them by a centre.
Summarising in rectangles uses :x, :y, :z and :group, and needs all three of :x,
:y and :z. A :z column must hold numbers. The tiles take what geom_bin_2d/3's take,
filled by their value through the fill scale, which titles the legend value, unless a fill
is mapped or set.
Summarising in rectangles computes, for each rectangle, value, and its middle, x and y. A
mapping reads them with an after_stat (Giggly.Mapping).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:tile, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:tile.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins- How many bins span each axis, when neitherbinwidth:norbreaks:is given: a whole number above 0 for both, or{x_bins, y_bins}. The default value is30.:binwidth- How wide and how high each rectangle is, in the axes' transformed units, which takes the place ofbins:: a number above 0 for both, or{width, height}.:breaks- Where the bins meet, two or more distinct numbers in the data's units, put through each axis's transformation, for both axes or as{x_breaks, y_breaks}, which takes the place ofbins:,binwidth:,center:andboundary:; a row outside them is not counted.:center- Where one bin's middle falls along each axis, which places them all: a number for both, or{x, y}; not withboundary:.:boundary- Where two bins meet along each axis, which places them all: a number for both, or{x, y}; not withcenter:. Without either, bins meet at 0.:closed- Which end of a bin a value on its edge belongs to, along each axis: the right end (:right) or the left (:left) for both, or{x_closed, y_closed}; the outermost bins hold their outer ends too. The default value is:right.:drop(boolean/0) - Whether to leave out each rectangle no row falls in;falsekeeps one at every x bin and y bin some row of its group falls in. The default value istrue.:fun- The summary of each rectangle'sz::mean,:median,:min,:max,:sum,:variance, the quantile{:quantile, probability: p}at a probability from 0 to 1, or a function of the rectangle's values, a list, returning a number ornil. The default value is:mean.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every tile's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given. A border takes no alpha but its colour's own.:fill- The colour every tile is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2, whose paper is clear.:linewidth- How wide every tile's border is, in millimetres; 0.4 times the theme'sbase_line_sizewhen not given, 0.2 at its default sizes.:linetype- The line type of every tile's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [1.0, 1.2, 2.5, 3.0, 4.0], "y" => [1.0, 1.1, 2.0, 3.5, 4.0], ...> "z" => [1.0, 2.0, 3.0, 4.0, 6.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z}) ...> |> Giggly.Plot.stat_summary_2d(binwidth: 1) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :value) [1.5, 3.0, 4.0, 6.0]
@spec stat_summary_bin(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer summarising the y values in bins of x: the x axis cut into bins, as
stat_bin/3 cuts it, and for each group a row at each bin some of its rows fall in, its x the
bin's middle, its y a summary of the values there and its ymin and ymax an interval round
it, drawn as point ranges unless geom: says otherwise, each as wide as its bin. It is
stat_summary/3 over bins, for a summary of many rows whose x values rarely repeat.
The summary is stat_summary/3's: given none, the mean less and plus one standard error;
fun_data: a whole summary by name, or fun:, fun_min: and fun_max: its values one at a
time. The bins are stat_bin/3's, the same in every group of a panel: bins: of them spanning
the axis, or binwidth: wide, placed by center: or boundary:, or meeting at breaks:,
closed as closed: says. A row outside the breaks given is summarised with the group's other
rows outside them, in a row of no x, which no geom draws.
Where y alone is discrete, the x values are summarised in bins of y instead, into x,
xmin and xmax, and the marks run across the panel; orientation: says which way, and
orientation: :y bins y beside a continuous x.
A summary in bins uses :x, :y and :group and the aesthetics its geom draws with, and needs
:x and :y; it writes the range, so :ymin, :ymax, :xmin and :xmax are not mapped,
and each mark's width, so a mapped :width groups the rows where it is discrete and is replaced
by the bin's. A row missing its x or y, or at an infinite one, is left out. Every other aesthetic goes to the
group's summaries where it holds one value in the group, and is dropped where it holds more, so
a discrete one groups the rows and gives each group its own summaries. On a discrete axis each
mark is 0.9 wide; a bar's, a crossbar's or an error bar's width: sets every mark's.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:pointrange, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:pointrange.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:fun_data- The whole summary at each position, itsy,yminandymax, by name, alone or in a tuple with its arguments,{:mean_sdl, mult: 1}::mean_se, the mean less and plusmult:standard errors (1);:mean_cl_normal, the mean and its confidence interval atconf_int:(0.95, from 0, below 1) from the t distribution, ormult:standard errors in place of the t;:mean_sdl, the mean less and plusmult:standard deviations (2);:median_hilow, the median and the quantiles holdingconf_int:(0.95, 0 to 1) of the values between them, as many either side; and:mean_cl_boot, the mean and its bootstrap interval atconf_int:(0.95, 0 to 1), fromresamples:(1000) resamples drawn fromseed:(0), any integer. Amult:is any number. Refused besidefun:,fun_min:orfun_max:;:mean_sewhen none of them is given.:fun- The summary'syat each position::mean,:median,:minor:max, or a function given the values there, a list of numbers in their rows' order, returning a number. Missing when not given besidefun_min:orfun_max:.:fun_min- The summary'syminat each position, asfun:gives itsy.:fun_max- The summary'symaxat each position, asfun:gives itsy.:orientation- Which way the summary runs::x, theyvalues summarised at eachx, or:y, thexvalues at eachy; when not given,:ywhereyalone is discrete, and:xotherwise.:bins- How many bins span the axis, when neitherbinwidth:norbreaks:is given, a whole number above 0, or a function handed a group's values that returns one. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own. The default value is30.:binwidth- How wide each bin is, a number above 0 in the axis's transformed units, or a function handed a group's values that returns one, which takes the place ofbins:. A function is handed each group's finite values along the axis, in its transformed units, so each group, in each panel, is cut at breaks of its own.:center- Where one bin's middle falls, which places them all; not withboundary:.:boundary- Where two bins meet, which places them all; not withcenter:. Without either, the outermost bins are centred on the axis's limits, or binsbinwidth:wide meet half a width from 0.:breaks- Where the bins meet, a list of two or more distinct numbers in the data's units, put through the axis's transformation, which takes the place ofbins:,binwidth:,center:andboundary:; the rows outside them are summarised together in one more row, at no place, which no geom draws.:closed- Which end of a bin a value on its edge belongs to: the right end (:right), or the left (:left); the outermost bins hold their outer ends too. The default value is:right.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:linewidth- How wide every line is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every line::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:color- The colour of every line and point, writtencolour:orcolor:, which outlines the point's shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres, each drawn four times as big; a third of the theme's points' size when not given, 0.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; twice the theme'sbase_line_sizewhen not given, 1 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function but orientation:, as stat_summary/3's
geoms do, and a bar's, crossbar's or error bar's width: is the summary's. Its position: is
:identity unless given, the bars' included.
Raises ArgumentError for fun_data: beside fun:, fun_min: or fun_max:, and for
center: beside boundary:; NimbleOptions.ValidationError for an option the geom does not
take, or a value it cannot use.
iex> frame =
...> %{"wt" => [1.5, 1.8, 2.6, 3.4, 3.9], "mpg" => [30.0, 32.0, 24.0, 18.0, 16.0]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.stat_summary_bin(fun: :mean, breaks: [1, 2, 3, 4])
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)}
{[1.5, 2.5, 3.5], [31.0, 24.0, 17.0]}
@spec stat_summary_hex(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of hexagons each summarising a third variable, :z, over the rows in it: the
plane cut into hexagons, as geom_hex/3 cuts it, and for each group a hexagon wherever a row
falls, filled by the mean of the z of its rows, or the summary fun: gives. A heatmap of how
a value varies over two others.
The hexagons are 30 across each panel's x and y axes unless bins: or binwidth: says
otherwise; each group's hexagons start from its own rows, so groups are binned apart. A row
falls in the hexagon whose centre is nearest. A row missing its x, y or z, or at an
infinite one, is left out. A hexagon whose summary is missing or NaN, as the variance of a
single value is, is left out unless drop: false keeps it. A panel where an axis has no
extent, as for rows all at one x, is drawn nothing.
Summarising in hexagons uses :x, :y, :z and :group, and needs all three of :x, :y
and :z. A :z column must hold numbers. The hexagons take what geom_hex/3's take, filled by
their value through the fill scale, which titles the legend value, unless a fill is mapped or
set.
Summarising in hexagons computes, for each hexagon, value, and its centre, x and y. A
mapping reads them with an after_stat (Giggly.Mapping).
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:hex, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:hex.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:bins- How many hexagons span each axis, whenbinwidth:is not given: a whole number above 0 for both, or{x_bins, y_bins}. The default value is30.:binwidth- How wide and how high each hexagon is, in the axes' transformed units, which takes the place ofbins:: a number above 0 for both, or{width, height}.:fun- The summary of each hexagon'sz::mean,:median,:min,:max,:sum,:variance, the quantile{:quantile, probability: p}at a probability from 0 to 1, or a function of the hexagon's values, a list, returning a number ornil. The default value is:mean.:drop(boolean/0) - Whether to leave out each hexagon whose summary is missing or NaN, as a variance of one value is;falsekeeps it, filled by the fill scale's colour for a missing value. The default value istrue.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:alpha- How opaque every hexagon's fill is, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every hexagon's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; no border when not given.:fill- The colour every hexagon is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, each hexagon is filled by its value, through the fill scale.:linewidth- How wide every hexagon's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every hexagon's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:lineend- How a line's ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square). The default value is:butt.:linejoin- How a border turns a corner: pointed (:mitre), rounded (:round) or cut off (:bevel); pointed when not given, and in a legend's keys the glyph's own: pointed for a rectangle's, rounded for a time series'.:linemitre- How far a pointed corner may reach, in widths of the line, before it is cut off; 1 or more. The default value is10.0.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"x" => [0.0, 0.1, 1.0, 2.0], "y" => [0.0, 0.1, 1.0, 2.0], ...> "z" => [1.0, 3.0, 5.0, 6.0]} ...> |> Giggly.Plot.new(%{x: :x, y: :y, z: :z}) ...> |> Giggly.Plot.stat_summary_hex(binwidth: 1) ...> |> Giggly.layer_data() iex> Giggly.DataFrame.pull(frame, :value) [2.0, 5.0, 6.0]
@spec stat_unique(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer drawing each distinct row once: within each panel, every row that repeats an
earlier one in all its columns, its positions, its other aesthetics and its group, is left out,
so marks that would fall exactly on one another are drawn once. Two values are alike where they
are equal, a missing value alike to a missing one; the rows kept are the first of each, in their
order, panel by panel. It draws points unless geom: names another geom; stat: :unique gives
any geom function the same stat.
It uses no aesthetic of its own and needs none: its geom takes the aesthetics its own function takes. A mapping's after_stat reads nothing the layer computes.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:point, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:point.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width given,{:dodge, width: width}, or each taken as that wide and set side by side with the marks it overlaps,{:dodge2, width: width}, having no width of their own to share, each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:identity.:alpha- How opaque every mark is, from 0, invisible, to 1, opaque.:color- The colour of every point, writtencolour:orcolor:, which outlines its shape and fills the shapes filled in it: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; black when not given.:fill- The colour every point of a shape with a fill of its own is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; none when not given.:shape- The shape every point is drawn in, by its name or its number, as listed above, a character, a string of one, drawn as that character,"."the smallest dot, or:nonefor no point;:circlewhen not given.:size- How big every point is, in millimetres; 1.5 times the theme'sbase_sizeover 11 when not given, 1.5 at its default sizes.:stroke- How heavy every point's outline is, in millimetres, or:nonefor no outline and no lines; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes. The outline is drawn half that wide, and a heavier stroke makes the shape bigger too.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.
Each geom takes the options of its own function, as geom: says. Its position: is
:identity unless given.
iex> frame =
...> GigDatasets.mtcars()
...> |> Giggly.Plot.new(%{x: :vs, y: :am})
...> |> Giggly.Plot.stat_unique(alpha: 0.1)
...> |> Giggly.layer_data()
iex> {Giggly.DataFrame.pull(frame, :x), Giggly.DataFrame.pull(frame, :y)}
{[0.0, 1.0, 1.0, 0.0], [1.0, 1.0, 0.0, 0.0]}
@spec stat_ydensity(t(), mapping_argument() | keyword(), keyword()) :: t()
Adds a layer of violins, the same layer geom_violin/3 adds: each group's densities along y,
drawn as a violin. It takes geom_violin/3's options, and computes and refuses what it does.
Options
:data(term/0) - A table for the layer to draw instead of the plot's data, anything implementingTable.Reader. The plot's mapping applies to it, so it must hold each column the plot's mapping names for an aesthetic the layer neither maps nor sets. Under a facet, a table lacking a faceting column is drawn in every panel of that column's values.:geom- The geom the layer's table is drawn with: one of Giggly's by the name of itsgeom_function,:pointdrawing points,:linea line,:colbars as tall as the table says. Given another geom than its own,:violin, the layer takes that geom's options, as its function documents them, in place of its own geom's, and its own position unlessposition:is given, which the geom's marks must take. The default value is:violin.:key_glyph- The glyph the layer's legend keys are drawn with instead of its geom's own::abline,:blank,:boxplot,:crossbar,:dotplot,:label,:linerange,:path,:point,:pointrange,:polygon,:rect,:smooth,:text,:timeseries,:vline,:vpath, each drawn as the geom of its name draws its keys,:polygonas a rectangle's,:rectas the key filled whole with its fill, or its colour where it has none, unbordered,:timeseriesas a path's through four points rising across the key, and:vpathas a path's turned up the key's middle, with the looks the layer's keys have and its own ends, corners and arrowhead where the glyph draws one. A look the glyph draws with that the layer has none of is the glyph's own, and the key's room is the glyph's, or else the key's size and line width added.:position- Where the marks are moved once the stat has run: left at their positions (:identity), piled on one another (:stack), piled to the same height (:fill), set side by side within the width one mark takes or the width given (:dodge), set side by side, each its share of their widths, with a gap between them (:dodge2), each moved a small random distance (:jitter), set side by side and then each moved a small random distance (:jitterdodge), or nudged (:nudge), each alone or with its options, as Positions says. The default value is:dodge.:bw- How smooth each curve is, its bandwidth, the kernel's standard deviation in the axis's transformed units: a number above 0, or a rule worked out from each group's rows, taking no weight: Silverman's rule of thumb (:nrd0), 0.9 times the lesser of the rows' standard deviation and their interquartile range over 1.34, times the rows to the power -0.2, or Scott's variation of it (:nrd), 1.06 times the lesser. The default value is:nrd0.:adjust- A multiple of the bandwidth, above 0:adjust: 0.5halves it, for a curve that follows the rows more closely, andadjust: 2doubles it, for a smoother one. The default value is1.0.:kernel- The shape put at each row and summed, scaled so its standard deviation is the bandwidth: a normal curve (:gaussian), a parabola (:epanechnikov), a block (:rectangular), a tent (:triangular), a parabola squared (:biweight), or a cosine's hump (:cosine) or a narrower one (:optcosine). The default value is:gaussian.:trim(boolean/0) - Whether each violin spans only its own group's extent;falsereaches three of the rule's bandwidths, beforeadjust:, past it either end, so its tails show. The default value istrue.:bounds- Limits the rows are known to lie within,{low, high}, the low a number or:neg_infinity, the high a number or:infinity, not below the low: the rows outside them are left out, and each curve's part beyond a finite one is folded back inside it, so the curve does not spill past a limit the data cannot. The default value is{:neg_infinity, :infinity}.:scale- How the violins are sized beside one another: each the same area (:area), as wide as its density makes it beside the panel's greatest; that times its rows over the panel's most, so a violin of more rows is bigger (:count); or each as wide at its widest (:width). The default value is:area.:quantiles- The quantiles of each group'sythe densities mark, each a row of its own whosequantileis its probability, a list of numbers from 0 to 1, or:nonefor noquantilecolumn at all. The default value is[0.25, 0.5, 0.75].:drop(boolean/0) - Whether to leave out a group of fewer than two rows, or,false, keep it as one row of missing densities, so a position makes room for it. The default value istrue.:width- How wide a violin's room is, in the units of the axis it stands on, any number; it replaces a mapped:width, and gives way to 0.9 of the range of a group spanning several positions. 0.9 times the closest spacing of the positions, counting from zero, when not given.:orientation- The axis the violins stand along,:xor:y, estimating the other; when not given they stand along the discrete one, or else along the axis on which every group holds one value, or else along x.:alpha- How opaque every violin's fill and quantile lines are, from 0, invisible, to 1, opaque; its border keeps its colour's own alpha.:color- The colour of every violin's border, writtencolour:orcolor:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; when not given, the theme's ink mixed 20% toward its paper,#333333, or#000000CCundertheme_void/2.:fill- The colour every violin is filled with: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; the theme's paper when not given, white, or clear undertheme_void/2.:linewidth- How wide every violin's border is, in millimetres; the theme'sbase_line_sizewhen not given, 0.5 at its default sizes.:linetype- The line type of every violin's border::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:solidwhen not given.:quantile_color- The colour of the lines across each violin at the quantiles its densities mark, writtenquantile_colour:orquantile_color:: a CSS colour name, such as"steelblue", a hex colour, such as"#4682B4", or"#4682B480"with an alpha of its own,"transparent", or:nonefor none; its violin's border colour when not given.:quantile_linetype- The line type of the lines across each violin at the quantiles its densities mark (quantiles:)::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed;:blank, drawing none, when not given. The default value is:blank.:quantile_linewidth- How wide the quantile lines are, in millimetres; their violin's border width when not given.:lineend- How the borders of the legend's keys end: cut square at the end (:butt), rounded (:round), or cut square half the line's width beyond it (:square); the violins' own borders are always cut square at the end. The default value is:butt.:linejoin- How the borders of the legend's keys turn a corner: pointed (:mitre), rounded (:round) or cut off (:bevel); when not given the glyph's own: pointed for a rectangle's, rounded for a time series'; the violins' own borders always turn rounded.:nudge_x- How far every mark moves along x from its place, in the units of the x axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.:nudge_y- How far every mark moves along y from its place, in the units of the y axis, besideposition: :nudge, which reads it, and refused beside another position; 0 when not given.iex> frame = ...> %{"g" => ["a", "a", "a"], "y" => [1.0, 2.0, 4.0]} ...> |> Giggly.Plot.new(%{x: :g, y: :y}) ...> |> Giggly.Plot.stat_ydensity(quantiles: :none) ...> |> Giggly.layer_data() iex> {Giggly.DataFrame.row_count(frame), Enum.at(Giggly.DataFrame.pull(frame, :y), 0)} {512, 1.0}
@spec theme(t(), keyword() | theme()) :: t()
@spec theme(theme(), keyword() | theme()) :: theme()
@spec theme(keyword(), []) :: theme()
Changes the look everything but the marks is drawn in: its backgrounds, grid lines, axes, strips, legends and titles, each an element of the theme, set by name.
The theme is a tree of elements, each inheriting what it leaves unset from its parent: every
text inherits from :text, every line from :line and every rectangle from :rect, so
text: [size: 14] makes every label bigger, and the x axis's tick labels below the panels,
:axis_text_x_bottom, inherit from :axis_text_x, which inherits from :axis_text. A line,
a rectangle or a text is a keyword list of the properties it sets; a size or a line width may be
{:rel, share}, a share of its parent's. A setting replaces only the properties it gives, so
theme(axis_text: [color: "red"]) keeps the labels' size, and a later call's properties replace
an earlier one's. A colour may have an alpha of its own ("#FF000080", "transparent"), drawn
at that opacity.
The settings are laid over the plot's complete theme, the default unless theme_gray/2,
theme_bw/2 or another chose one. After a chosen theme each call is laid over it in turn, so
an element set after a call removed it replaces the theme's element whole, inheriting what it
leaves unset from its parent; a plot that chose none merges its calls first and lays them over
the default at once, so there the element keeps the default's own properties. A line, a
rectangle or a text given as {:replace, element} replaces the theme's element whole, chosen
or the default, so the properties it leaves unset come from its parent:
theme(panel_grid_minor: {:replace, [colour: "red"]}) draws the minor grid lines red and as
wide as the major ones, where [colour: "red"] keeps the default's half width. A later call's
properties merge into the replacement.
A line's linetype: and lineend: and a rectangle's linetype:, its border's, take what a
layer's take: a line of the blank line type draws nothing but keeps its room, as an axis's
ticks do, and a border of it is no border. A rectangle's fill: :none leaves it unfilled. The
axes' lines (:axis_line) and the panels' border (:panel_border), drawn over the layers and
never filled, are removed until a setting gives them, and panel_ontop: true draws the panels'
backgrounds and grid lines over the layers, under the border.
A text's face: makes it bold or italic, angle: turns it, and hjust: and vjust: place it
in its room: the room is as deep as the turned text, so axis_text_x: [angle: 45, hjust: 1]
turns the x axis's labels to end at their ticks and deepens the axis to fit them, and
plot_title: [hjust: 0.5] centres the title over the panels, or over the whole plot with
plot_title_position: :plot, which lines the title and the subtitle up with everything between
the tag and the margin, as plot_caption_position: :plot does the caption. The justification is the text's
own, along and across it once turned: the y axis's title is turned 90 degrees, so its vjust: 1 puts its top toward the left. A legend's labels sit right of their keys, left-aligned and
centred on them, and its title is left-aligned, unless :legend_text or :legend_title says
otherwise; :text's justification never reaches them. lineheight: spaces a text's lines,
a tick label's and a legend's as a title's.
family: names the font a text is drawn in, inherited as any property is: title: [family: "mono"] reaches the axes' titles, the legends' titles and the plot's title, and text: [family: "serif"] every text but a layer's, which takes the complete theme's base_family.
How a family is measured and drawn, with Pica or without it: the fonts guide.
A length is a number of ggplot2's points (1/72.27 inch), {amount, unit} in :pt, :cm,
:mm, :in or :lines, a line of text, or {:rel, share}, a share of its parent's. A margin
is one length for every side, a keyword list of :top, :right, :bottom and :left, a side
left out 0, or {:rel, share}. :spacing and :margins, which inherit from nothing, take no
share.
A line, a rectangle or a text set to :none is removed: it draws nothing and takes no room, and
the elements that inherit from it go with it, so axis_text: :none removes every axis's tick
labels and the room they took. An element a setting gives is drawn all the same, inheriting from
the nearest element above it that is not removed, so theme(axis_text: :none, axis_text_x: [color: "red"]) keeps the x axis's labels, red and at the size of :text; a later setting of a
removed element replaces the removal. Under a removed :line, :rect or :text, a property
nothing above an element gives is drawn at the drawing's own default: black, filled white, a
solid line 0.75 points wide with round ends, text 12 points with its lines 1.2 sizes apart, and no
margin.
The legends go right of the panels unless legend_position: puts them left of the panels
(:left), above (:top) or below (:bottom), inside them (:inside), or nowhere (:none),
where a guide's own position: does not put its legend elsewhere; :none draws none at all,
those guides' too. The legends going to one side share a box, and inside the panels those going
to one point at one justification, a guide's own theme's or else these.
Beside the panels they are stacked in a box the theme's spacing from them, one above another on
the left and right and side by side above and below, their keys running down and across; a box
above or below the panels sits below the plot's title and above its caption, and one on the left
outside the y axis's title. legend_direction: runs every legend's keys one way, and
legend_box: arranges the legends one way, wherever they go. Which point of the box is placed
at the same point of the room beside the panels is its justification, :center unless
legend_justification: or the side's own (legend_justification_right: and the rest) says
otherwise: :top hangs a box right of the panels from their top. The room beside the panels is
as long as the panels, or as the whole plot with legend_location: :plot. Inside the panels,
the box's justification is placed at legend_position_inside:, {x, y} as shares of the panels'
width and height, or at the same point of the panels when none is given, so legend_position: :inside, legend_justification_inside: {1, 0} puts the box in the panels' bottom right corner.
legend_box_just: places each legend in the box, legend_box_margin: spaces them from its
edge, and legend_box_background: draws its background, which no complete theme draws, as its
setting gives it, taking nothing from :rect: legend_box_background: [] is white with a black
border 0.75 points wide.
The tag goes in the top left corner, in a row and a column of its own inside the margin, unless
plot_tag_position: puts it at another corner or a side, :top centring it in a row of its own
across the whole plot and :left in a column down it, or at a point, {x, y}.
plot_tag_location: :plot places it over everything inside the margin and :panel over the
panels, taking no room, at the same corner or side, or at the point as shares of what it is
placed in; a point goes over everything inside the margin unless it says :panel, and cannot
go in the margin.
A theme of its own
A theme can be built apart from any plot and kept, to give several plots one look. Given its
settings alone, theme/2 returns a theme of those settings, and a complete theme function given
its options alone (theme_bw(base_size: 12)) returns that complete theme; either piped into
theme/2, or given a theme where it takes a plot, adds to it, and so do the theme shortcuts.
A theme is added to a plot, or to another theme, as a call's settings are: one that chose a
complete theme replaces the theme before it whole, its settings dropped, as choosing that
complete theme would; one of settings alone lays them over it, each as it is recorded, so a
replacement it holds still replaces. A guide's theme: takes a theme of settings alone too.
Raises NimbleOptions.ValidationError for an element it does not know or a value it cannot use,
and ArgumentError for an element or a property given twice, or for a tag placed at a point in
the margin, by this call's settings and the plot's earlier ones together.
Options
:line(keyword/0) - Every line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:rect(keyword/0) - Every rectangle: backgrounds and borders.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:text(keyword/0) - Every text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:title(keyword/0) - Every title: the axes', the legends' and the plot's. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:spacing- Every spacing between parts of the plot.:margins- Every margin inside a part of the plot.:geom(keyword/0) - The layers' defaults, ggplot2'selement_geom(): the colours, widths, line types, font and points a layer draws with where it neither maps nor sets them. A setting replaces only the properties it gives; given as{:replace, element}, those it leaves out aretheme_gray/2's at its default sizes, whatever the plot's complete theme.:ink- The colour layers draw in, and mix their fills from with the paper, a CSS colour, which may have an alpha of its own.:paper- The colour layers mix their fills from with the ink, asink:takes one.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.:color- The colour every layer draws its lines and outlines in, in place of its own, a CSS colour, or:nonefor none (colour:too).:fill- The fill every layer fills its shapes with, in place of its own, a CSS colour, or:nonefor none.:linewidth- How wide the layers' lines are, in millimetres, 0 or more.:borderwidth- How wide the layers' borders are, in millimetres, 0 or more.:linetype- The layers' lines' line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:bordertype- The layers' borders' line type, aslinetype:takes one.:family(String.t/0) - The font the layers' text is drawn in, as a text element'sfamily:names one.:fontsize- How big the layers' text is, in points, 0 or more.:pointsize- How big the layers' points are, in millimetres, 0 or more.:pointshape- The layers' points' shape, as a layer'sshape:takes one.
:axis_line(keyword/0) - The axes' lines, along the panels' edges. Inherits from:line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_text(keyword/0) - The axes' tick labels. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_ticks(keyword/0) - The axes' ticks. Inherits from:line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_title(keyword/0) - The axes' titles. Inherits from:title.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_line_x(keyword/0) - The x axis's line. Inherits from:axis_line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_x_bottom(keyword/0) - The line of the x axis below the panels. Inherits from:axis_line_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_x_top(keyword/0) - The line of the x axis above the panels. Inherits from:axis_line_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_y(keyword/0) - The y axis's line. Inherits from:axis_line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_y_left(keyword/0) - The line of the y axis left of the panels. Inherits from:axis_line_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_y_right(keyword/0) - The line of the y axis right of the panels. Inherits from:axis_line_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_theta(keyword/0) - The line round a radial panel's circle. Inherits from:axis_line_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_line_r(keyword/0) - The line of a radial panel's radius axis. Inherits from:axis_line_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_text_x(keyword/0) - The x axis's tick labels. Inherits from:axis_text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_x_bottom(keyword/0) - The tick labels of the x axis below the panels. Inherits from:axis_text_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_x_top(keyword/0) - The tick labels of the x axis above the panels. Inherits from:axis_text_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_y(keyword/0) - The y axis's tick labels. Inherits from:axis_text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_y_left(keyword/0) - The tick labels of the y axis left of the panels. Inherits from:axis_text_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_y_right(keyword/0) - The tick labels of the y axis right of the panels. Inherits from:axis_text_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_theta(keyword/0) - The tick labels round a radial panel. Inherits from:axis_text_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_text_r(keyword/0) - The tick labels of a radial panel's radius axis. Inherits from:axis_text_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_ticks_length- How long the axes' ticks are. Inherits from:spacing.:axis_ticks_length_x- How long the x axis's ticks are. Inherits from:axis_ticks_length.:axis_ticks_length_x_bottom- How long the ticks of the x axis below the panels are. Inherits from:axis_ticks_length_x.:axis_ticks_length_x_top- How long the ticks of the x axis above the panels are. Inherits from:axis_ticks_length_x.:axis_ticks_length_y- How long the y axis's ticks are. Inherits from:axis_ticks_length.:axis_ticks_length_y_left- How long the ticks of the y axis left of the panels are. Inherits from:axis_ticks_length_y.:axis_ticks_length_y_right- How long the ticks of the y axis right of the panels are. Inherits from:axis_ticks_length_y.:axis_ticks_length_theta- How long the ticks round a radial panel are. Inherits from:axis_ticks_length_x.:axis_ticks_length_r- How long the ticks of a radial panel's radius axis are. Inherits from:axis_ticks_length_y.:axis_ticks_x(keyword/0) - The x axis's ticks. Inherits from:axis_ticks.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_x_bottom(keyword/0) - The ticks of the x axis below the panels. Inherits from:axis_ticks_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_x_top(keyword/0) - The ticks of the x axis above the panels. Inherits from:axis_ticks_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_y(keyword/0) - The y axis's ticks. Inherits from:axis_ticks.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_y_left(keyword/0) - The ticks of the y axis left of the panels. Inherits from:axis_ticks_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_y_right(keyword/0) - The ticks of the y axis right of the panels. Inherits from:axis_ticks_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_theta(keyword/0) - The ticks round a radial panel. Inherits from:axis_ticks_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_ticks_r(keyword/0) - The ticks of a radial panel's radius axis. Inherits from:axis_ticks_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_x_top(keyword/0) - The minor ticks of the x axis above the panels. Inherits from:axis_ticks_x_top.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_x_bottom(keyword/0) - The minor ticks of the x axis below the panels. Inherits from:axis_ticks_x_bottom.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_y_left(keyword/0) - The minor ticks of the y axis left of the panels. Inherits from:axis_ticks_y_left.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_y_right(keyword/0) - The minor ticks of the y axis right of the panels. Inherits from:axis_ticks_y_right.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_theta(keyword/0) - The minor ticks round a radial panel. Inherits from:axis_ticks_theta.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_r(keyword/0) - The minor ticks of a radial panel's radius axis. Inherits from:axis_ticks_r.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:axis_minor_ticks_length- How long the axes' minor ticks are.:axis_minor_ticks_length_x- How long the x axis's minor ticks are. Inherits from:axis_minor_ticks_length.:axis_minor_ticks_length_x_top- How long the minor ticks of the x axis above the panels are. Inherits from:axis_minor_ticks_length_x, then from:axis_ticks_length_x_top.:axis_minor_ticks_length_x_bottom- How long the minor ticks of the x axis below the panels are. Inherits from:axis_minor_ticks_length_x, then from:axis_ticks_length_x_bottom.:axis_minor_ticks_length_y- How long the y axis's minor ticks are. Inherits from:axis_minor_ticks_length.:axis_minor_ticks_length_y_left- How long the minor ticks of the y axis left of the panels are. Inherits from:axis_minor_ticks_length_y, then from:axis_ticks_length_y_left.:axis_minor_ticks_length_y_right- How long the minor ticks of the y axis right of the panels are. Inherits from:axis_minor_ticks_length_y, then from:axis_ticks_length_y_right.:axis_minor_ticks_length_theta- How long the minor ticks round a radial panel are. Inherits from:axis_minor_ticks_length_x, then from:axis_ticks_length_theta.:axis_minor_ticks_length_r- How long the minor ticks of a radial panel's radius axis are. Inherits from:axis_minor_ticks_length_y, then from:axis_ticks_length_r.:axis_title_x(keyword/0) - The x axis's title. Inherits from:axis_title.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_title_x_bottom(keyword/0) - The title of the x axis below the panels. Inherits from:axis_title_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_title_x_top(keyword/0) - The title of the x axis above the panels. Inherits from:axis_title_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_title_y(keyword/0) - The y axis's title. Inherits from:axis_title.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_title_y_left(keyword/0) - The title of the y axis left of the panels. Inherits from:axis_title_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:axis_title_y_right(keyword/0) - The title of the y axis right of the panels. Inherits from:axis_title_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:legend_background(keyword/0) - Each legend's background. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:legend_margin- The margin inside each legend's edge. Inherits from:margins.:legend_spacing- The space between legends. Inherits from:spacing.:legend_spacing_x- The space between a legend and the next beside it. Inherits from:legend_spacing.:legend_spacing_y- The space between a legend and the next below it. Inherits from:legend_spacing.:legend_key(keyword/0) - The background of each legend key. Inherits from:panel_background.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:legend_key_size- How big each legend key is. Inherits from:spacing.:legend_key_height- How tall each legend key is. Inherits from:legend_key_size.:legend_key_width- How wide each legend key is. Inherits from:legend_key_size.:legend_key_spacing- The space between a legend's keys and its labels, and below its title. Inherits from:spacing.:legend_key_spacing_x- The space between a legend's columns of keys. Inherits from:legend_key_spacing.:legend_key_spacing_y- The space between a legend's rows of keys; none in a legend running down unless set. Inherits from:legend_key_spacing.:legend_key_justification- Where a legend key smaller than its row and column sits in them, as:legend_justificationtakes; filling them when not given.:legend_byrow(boolean/0) - Whether a legend's keys fill its rows first,true, or its columns,false.:legend_axis_line(keyword/0) - The line along a legend's axis, a binned legend's. Inherits from:line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:legend_ticks(keyword/0) - A colour bar's ticks, colour steps' and a binned legend's. Inherits from:legend_axis_line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:legend_ticks_length- How far a colour bar's or colour steps' ticks reach into the bar. Inherits from:legend_key_size.:legend_frame(keyword/0) - The border round a colour bar's bar, and colour steps', never filled; none unless set. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:legend_text(keyword/0) - The legends' labels. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:legend_title(keyword/0) - The legends' titles. Inherits from:title.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:legend_text_position- Which side of a legend's keys its labels go on::top,:right,:bottomor:left; a colour bar's or colour steps' along the bar alone, either side of one running up and above or below one running across. Right of a legend's keys, and of a bar running up, and below a bar running across, unless given.:legend_title_position- Which side of a legend's keys its title goes on::top,:right,:bottomor:left; above keys running down and left of keys running across unless given.:legend_position- Where the legends go::right,:left,:topor:bottom, beside the panels on that side,:inside, over them, or:none, for no legends.:legend_position_inside- Where the legends' box goes when they are inside the panels:{x, y}, each a share of the panels' width or height from their left or bottom; at its justification unless given.:legend_direction- Which way each legend's keys run::horizontalor:vertical; across above or below the panels and down elsewhere unless given.:legend_justification- Which point of the legends' box is placed where it goes::center, a side (:left,:right,:top,:bottom), or{horizontal, vertical}, each a share of the box's width or height or:left,:centeror:rightacross and:bottom,:centeror:topup; beside the panels, the same point of the room beside them.:legend_justification_top- The justification of legends above the panels. Inherits from:legend_justification.:legend_justification_bottom- The justification of legends below the panels. Inherits from:legend_justification.:legend_justification_left- The justification of legends left of the panels. Inherits from:legend_justification.:legend_justification_right- The justification of legends right of the panels. Inherits from:legend_justification.:legend_justification_inside- The justification of legends inside the panels. Inherits from:legend_justification.:legend_location- What legends beside the panels line up with::panel, the panels, or:plot, the axes and their titles too.:legend_box- How several legends are arranged::horizontal, side by side, or:vertical, one above another; side by side above or below the panels and one above another elsewhere unless given.:legend_box_just- Which point of each legend is placed at the same point of its room in the box: as:legend_justificationtakes, by name alone; at the box's top, centred across above or below the panels and at its left elsewhere, unless given.:legend_box_margin- The margin inside the legends' box. Inherits from:margins.:legend_box_background(keyword/0) - The background of the legends' box, over its margin too, drawn as its own setting gives it: what that leaves unset is the drawing's default, a white fill and a solid black border 0.75 points wide, never:rect's.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:legend_box_spacing- The space between the panels and the legends. Inherits from:spacing.:panel_background(keyword/0) - The panels' background, under the layers. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:panel_border(keyword/0) - The panels' border, drawn over the layers and never filled. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:panel_spacing- The space between panels. Inherits from:spacing.:panel_spacing_x- The space between panels side by side. Inherits from:panel_spacing.:panel_spacing_y- The space between panels one above another. Inherits from:panel_spacing.:panel_grid(keyword/0) - The panels' grid lines. Inherits from:line.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_major(keyword/0) - The grid lines at the axes' breaks. Inherits from:panel_grid.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_minor(keyword/0) - The grid lines between the axes' breaks. Inherits from:panel_grid.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_major_x(keyword/0) - The grid lines at the x axis's breaks. Inherits from:panel_grid_major.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_major_y(keyword/0) - The grid lines at the y axis's breaks. Inherits from:panel_grid_major.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_minor_x(keyword/0) - The grid lines between the x axis's breaks. Inherits from:panel_grid_minor.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_grid_minor_y(keyword/0) - The grid lines between the y axis's breaks. Inherits from:panel_grid_minor.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.:lineend- How its ends are drawn: cut square at the end (:butt), rounded (:round), or cut square half its width beyond it (:square).:arrow- An arrowhead at the end of each of its lines:truefor the default, or a keyword list ofangle:(30),length:({0.25, :in}),ends:(:last,:firstor:both),type:(:openor:closed) andfill:(the line's colour unless given), as a layer'sarrow:takes them. Only the element given it and those the theme leaves out under it draw one: a line the theme or a setting gives without an arrow has none.
:panel_ontop(boolean/0) - Whether the panels' background and grid lines are drawn over the layers,true, or under them,false.:panel_widths- How wide the panels are: one length, the width of them all from the first's left edge to the last's right, the space and axes between them included, shared as their scales share it; or a list of lengths, each column's in turn, begun again when it runs out.:none, the default, leaves them what the drawing's space leaves them. A single panel keeping its shape is as tall as its width and shape make it unlesspanel_heightssays otherwise; several keep it no longer, as tall as the drawing's space leaves them.:panel_heights- How tall the panels are: one length, the height of them all from the first's top edge to the last's bottom, the space, axes and strips between them included, shared as their scales share it; or a list of lengths, each row's in turn, begun again when it runs out.:none, the default, leaves them what the drawing's space leaves them. A single panel keeping its shape is as wide as its height and shape make it unlesspanel_widthssays otherwise; several keep it no longer, as wide as the drawing's space leaves them.:strip_background(keyword/0) - The strips' background. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:strip_background_x(keyword/0) - The background of the strips above or below panels. Inherits from:strip_background.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:strip_background_y(keyword/0) - The background of the strips left or right of panels. Inherits from:strip_background.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:strip_clip- Whether each strip's background and label are cut off at its edges,:on, or not,:offor:inherit.:strip_placement- Whether strips beside axes sit between the panel and the axis,:inside, or beyond the axis,:outside;:insideunless given.:strip_placement_x- Where the strips above or below panels sit beside the x axes. Inherits from:strip_placement.:strip_placement_y- Where the strips left or right of panels sit beside the y axes. Inherits from:strip_placement.:strip_text(keyword/0) - The strips' labels. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_x(keyword/0) - The labels of the strips above or below panels. Inherits from:strip_text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_x_bottom(keyword/0) - The labels of the strips below panels. Inherits from:strip_text_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_x_top(keyword/0) - The labels of the strips above panels. Inherits from:strip_text_x.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_y(keyword/0) - The labels of the strips left or right of panels. Inherits from:strip_text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_y_left(keyword/0) - The labels of the strips left of panels. Inherits from:strip_text_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_text_y_right(keyword/0) - The labels of the strips right of panels. Inherits from:strip_text_y.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:strip_switch_pad_grid- The space between afacet_grid/2strip placed outside the axes and the axes, on a side with an axis. Inherits from:spacing.:strip_switch_pad_wrap- The space between afacet_wrap/3strip placed outside the axes and the axes, in each row or column of panels with an axis on that side. Inherits from:spacing.:plot_background(keyword/0) - The background of the whole plot. Inherits from:rect.:fill- Its fill, a CSS colour, which may have an alpha of its own, or:nonefor none.:color- Its border's colour, a CSS colour, which may have an alpha of its own, or:nonefor no border (colour:too).:linewidth- How wide it is, in millimetres, or{:rel, share}, a share of its parent's.:linetype- Its line type::blank, which draws no line,:solid,:dashed,:dotted,:dotdash,:longdashor:twodash, or its number in that order, 0 to 6; or a dash pattern, a tuple of 2, 4, 6 or 8 lengths from 1 to 15, a dash and a gap in turn, which grow with the line's width,{4, 4}being:dashed.
:plot_margin- The margin round the whole plot. Inherits from:margins.:plot_title(keyword/0) - The plot's title. Inherits from:title.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:plot_title_position- What the plot's title and subtitle line up with::panel, the panels, or:plot, everything inside the margin and the tag.:plot_subtitle(keyword/0) - The plot's subtitle. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:plot_caption(keyword/0) - The plot's caption. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:plot_caption_position- What the plot's caption lines up with::panel, the panels, or:plot, everything inside the margin and the tag.:plot_tag(keyword/0) - The plot's tag. Inherits from:text.:color- Its colour, a CSS colour, which may have an alpha of its own (colour:too).:size- How big it is, in points, or{:rel, share}, a share of its parent's size.:family(String.t/0) - The font it is drawn in, by name, such as"Lobster", or one of the generic families"sans","serif"and"mono";""is the default sans-serif. How it is measured and drawn: the fonts guide.:face- Its face::plain,:bold,:italicor:bold_italic.:angle- How far it is turned, in degrees anticlockwise, any number.:hjust- Where it sits across, any number: 0 at its left, 0.5 centred, 1 at its right, in its own turned frame.:vjust- Where it sits up, any number: 0 at its bottom, 0.5 centred, 1 at its top, in its own turned frame.:lineheight- How far apart its lines are, 0 or more, a share of 1.2 times its size: a text's lines are 0.9 apart unless given.:margin- The space on each side of it: one length for every side, or a keyword list of:top,:right,:bottomand:left, a side left out 0.
:plot_tag_position- Where the plot's tag goes: a corner or a side,:topleft,:top,:topright,:left,:right,:bottomleft,:bottomor:bottomright, or a point{x, y}, each a share of what it is placed in, from the left and from the bottom.:plot_tag_location- What the plot's tag is placed in::margin, a row or column of its own between the margin and everything else,:plot, everything inside the margin, or:panel, the panels, the last two taking no room. Unset, it is:plotfor a point and:marginfor a corner or a side; a point cannot be placed in the margin.:palette_color_discrete- The palette a discrete colour scale given none of its own takes,Giggly.Plot.scale_color_discrete/2's or the one a discrete column gets by default: a palette's name, such as"Dark2", or a list of colours, in order. Hues spaced evenly round the colour wheel unless given.:palette_color_continuous- The palette a continuous or binned colour scale given none of its own takes,Giggly.Plot.scale_color_continuous/2's,Giggly.Plot.scale_color_binned/2's or the one a column of numbers gets by default: a palette's name, such as"Blues", or a list of colours, a gradient through them. A gradient from#132B43to#56B1F7unless given.:palette_fill_discrete- The palette a discrete fill scale given none of its own takes, as:palette_color_discretefor colour. Inherits from:palette_color_discrete.:palette_fill_continuous- The palette a continuous or binned fill scale given none of its own takes, as:palette_color_continuousfor colour. Inherits from:palette_color_continuous.:palette_alpha_discrete- The palette a discrete or ordinal alpha scale given norange:takes: a palette of opacities from 0 to 1,{:rescale, {low, high}}, spread evenly over the values,{:area, {low, high}}, or{:manual, opacities}, in order. 0.1 to 1 unless given.:palette_alpha_continuous- The palette a continuous, binned, date or date-time alpha scale given norange:takes:{:rescale, {low, high}},{:area, {low, high}}or{:manual, opacities}, joined by straight lines, each from 0 to 1. 0.1 to 1 unless given.:palette_linewidth_discrete- The palette a discrete or ordinal line width scale given norange:takes, in millimetres, each 0 or more, as:palette_alpha_discretetakes opacities. 2 to 6 unless given.:palette_linewidth_continuous- The palette a continuous, binned, date or date-time line width scale given norange:takes, in millimetres, each 0 or more, as:palette_alpha_continuoustakes opacities. 1 to 6 unless given.:palette_size_discrete- The palette a discrete or ordinal size scale given norange:takes, in millimetres, each 0 or more, as:palette_alpha_discretetakes opacities. 2 to 6 by area unless given.:palette_size_continuous- The palette a continuous, binned, date or date-time size scale given norange:takes, in millimetres, each 0 or more, as:palette_alpha_continuoustakes opacities:{:area, {low, high}}for sizes that grow by area. 1 to 6 by area unless given.:palette_shape_discrete- The palette a discrete shape scale given nosolid:takes: a list of shapes, by name or number, in order,{:manual, shapes}alike, or{:shape, :solid}or{:shape, :open}, six solid or open shapes. The solid ones unless given.:palette_linetype_discrete- The palette a discrete line type scale takes: a list of line types, by name, number or dash pattern, in order,{:manual, line_types}alike, or:linetype, R's 13. R's 13 unless given.:aspect_ratio- The shape every panel keeps, its height over its width, any number, a negative one drawn as its size, over the coordinate system's own shape,coord_fixed/2's ratio included;:none, the default, leaves the shape to the coordinate system. A facet sizing its panels by their scales (space:) refuses one when the plot is run.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme(panel_background: [fill: "white"], axis_text: [color: "red"]) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "fill: #EBEBEB", svg =~ "fill: #FF0000"} {false, true}
Removing the panel's background and the tick labels leaves the axes' titles the only text:
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.theme(panel_background: :none, axis_text: :none)
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ "fill: #EBEBEB", length(Regex.scan(~r/<text/, svg))}
{false, 2}Drawing the axes' lines, and a dashed, unfilled border over the panel:
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.theme(
...> axis_line: [colour: "black"],
...> panel_border: [colour: "black", linetype: :dashed]
...> )
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {length(Regex.scan(~r/<polyline[^>]*#000000/, svg)),
...> svg =~ "stroke: #000000; stroke-dasharray: 5.69,5.69; fill: none;"}
{2, true}A look kept as a theme, chosen and set once, and given to a plot:
iex> house =
...> Giggly.Plot.theme_bw(base_size: 12)
...> |> Giggly.Plot.theme(panel_grid_minor: :none, legend_position: :bottom)
iex> house.settings
%{panel_grid_minor: :none, legend_position: :bottom}
iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg})
iex> Giggly.Plot.theme(plot, house) ==
...> plot
...> |> Giggly.Plot.theme_bw(base_size: 12)
...> |> Giggly.Plot.theme(panel_grid_minor: :none, legend_position: :bottom)
trueAdding keeps the properties an element leaves unset, where replacing drops them:
iex> Giggly.Plot.theme_gray() |> Giggly.Plot.theme(text: [family: "Times"]) |> Map.fetch!(:settings)
%{text: %{family: "Times"}}
iex> Giggly.Plot.theme_gray()
...> |> Giggly.Plot.theme(text: {:replace, [family: "Times"]})
...> |> Map.fetch!(:settings)
%{text: {:replace, %{family: "Times"}}}
Draws everything but the marks dark on light: a white panel bordered in dark grey, with light grey grid lines, and light grey strips bordered as the panel is.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_bw() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "fill: #EBEBEB", svg =~ "stroke: #333333; fill: none;"} {false, true}
Draws the axes as lines, with no grid: black axis lines with square ends, black ticks and tick labels, no border round the panel, and white strips bordered in black.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_classic() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "stroke-linecap: square", svg =~ "stroke: #FFFFFF; stroke-linecap: butt"} {true, false}
Draws everything but the marks on a dark panel: a mid-grey panel, and legend keys, with darker grid lines half as wide as a line, the minor ones a quarter, thin dark grey ticks, and near-black strips with near-white labels.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_dark() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "fill: #7F7F7F", svg =~ "stroke: #6B6B6B"} {true, true}
Draws everything but the marks in the default theme, in the colours and at the base sizes given: a grey panel with white grid lines, the minor ones half as wide, dark grey ticks, grey tick labels, and light grey strips, each grey the ink mixed toward the paper.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_gray(base_size: 16) ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "fill: #EBEBEB", svg =~ "font-size: 12.80px"} {true, true}
Its text in a serif font, and its titles, here the axes', in a monospaced one:
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.theme_gray(base_family: "serif", header_family: "mono")
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ "font-family: serif;", svg =~ "font-family: monospace;"}
{true, true}In navy ink on ivory paper, the points navy and the panel the ink 92% of the way toward the paper:
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.theme_gray(ink: "navy", paper: "ivory")
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> {svg =~ "fill: #000080", svg =~ "fill: #EBEBE7"}
{true, true}
Draws everything but the marks in light grey lines on white: a white panel bordered in light grey, lighter grey grid lines half as wide as a line, the minor ones a quarter, light grey ticks, and light grey strips with white labels.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_light() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "stroke: #B3B3B3; fill: none;", svg =~ "stroke: #DEDEDE"} {true, true}
Draws everything but the marks in black lines of various widths on white: a white panel bordered in black, black grid lines a tenth of a line wide, the minor ones a twentieth, black ticks and tick labels, and black strips with white labels.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_linedraw() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "fill: #4D4D4D", svg =~ "stroke-width: 0.11; stroke: #000000;"} {false, true}
Draws nothing behind the marks but their grid lines: no panel background, border or ticks, the tick labels further from the panel in their stead, no background to the strips, the legends or their keys, and a white plot background with no border.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_minimal() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "stroke: #EBEBEB", svg =~ "fill: #EBEBEB", svg =~ "stroke: #333333"} {true, false, false}
@spec theme_sub_axis(t(), keyword()) :: t()
@spec theme_sub_axis(theme(), keyword()) :: theme()
@spec theme_sub_axis(keyword(), []) :: theme()
Sets the elements of every axis by shorter names: text: sets axis_text, every axis's tick
labels.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title: The axes' titles.:text(term/0) - Sets:axis_text: The axes' tick labels.:ticks(term/0) - Sets:axis_ticks: The axes' ticks.:ticks_length(term/0) - Sets:axis_ticks_length: How long the axes' ticks are.:line(term/0) - Sets:axis_line: The axes' lines, along the panels' edges.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length: How long the axes' minor ticks are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis(plot, text: [size: 12], ticks_length: 4) == ...> Giggly.Plot.theme(plot, axis_text: [size: 12], axis_ticks_length: 4) true
@spec theme_sub_axis_bottom(t(), keyword()) :: t()
@spec theme_sub_axis_bottom(theme(), keyword()) :: theme()
@spec theme_sub_axis_bottom(keyword(), []) :: theme()
Sets the elements of the x axis below the panels by shorter names: text: sets
axis_text_x_bottom.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_x_bottom: The title of the x axis below the panels.:text(term/0) - Sets:axis_text_x_bottom: The tick labels of the x axis below the panels.:ticks(term/0) - Sets:axis_ticks_x_bottom: The ticks of the x axis below the panels.:ticks_length(term/0) - Sets:axis_ticks_length_x_bottom: How long the ticks of the x axis below the panels are.:line(term/0) - Sets:axis_line_x_bottom: The line of the x axis below the panels.:minor_ticks(term/0) - Sets:axis_minor_ticks_x_bottom: The minor ticks of the x axis below the panels.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_x_bottom: How long the minor ticks of the x axis below the panels are.
Drawing the bottom axis's title, labels, line and ticks in red:
iex> svg =
...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.theme_sub_axis_bottom(
...> title: [colour: "red"],
...> text: [colour: "red"],
...> line: [colour: "red"],
...> ticks: [colour: "red"]
...> )
...> |> Giggly.to_svg()
...> |> IO.iodata_to_binary()
iex> svg =~ "fill: #FF0000"
trueIt sets what theme/2 sets with the names written out:
iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg})
iex> Giggly.Plot.theme_sub_axis_bottom(plot, text: [colour: "red"], minor_ticks: :none) ==
...> Giggly.Plot.theme(plot,
...> axis_text_x_bottom: [colour: "red"],
...> axis_minor_ticks_x_bottom: :none
...> )
true
@spec theme_sub_axis_left(t(), keyword()) :: t()
@spec theme_sub_axis_left(theme(), keyword()) :: theme()
@spec theme_sub_axis_left(keyword(), []) :: theme()
Sets the elements of the y axis left of the panels by shorter names: text: sets
axis_text_y_left.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_y_left: The title of the y axis left of the panels.:text(term/0) - Sets:axis_text_y_left: The tick labels of the y axis left of the panels.:ticks(term/0) - Sets:axis_ticks_y_left: The ticks of the y axis left of the panels.:ticks_length(term/0) - Sets:axis_ticks_length_y_left: How long the ticks of the y axis left of the panels are.:line(term/0) - Sets:axis_line_y_left: The line of the y axis left of the panels.:minor_ticks(term/0) - Sets:axis_minor_ticks_y_left: The minor ticks of the y axis left of the panels.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_y_left: How long the minor ticks of the y axis left of the panels are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis_left(plot, ticks_length: {2, :mm}) == ...> Giggly.Plot.theme(plot, axis_ticks_length_y_left: {2, :mm}) true
@spec theme_sub_axis_right(t(), keyword()) :: t()
@spec theme_sub_axis_right(theme(), keyword()) :: theme()
@spec theme_sub_axis_right(keyword(), []) :: theme()
Sets the elements of the y axis right of the panels by shorter names: text: sets
axis_text_y_right.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_y_right: The title of the y axis right of the panels.:text(term/0) - Sets:axis_text_y_right: The tick labels of the y axis right of the panels.:ticks(term/0) - Sets:axis_ticks_y_right: The ticks of the y axis right of the panels.:ticks_length(term/0) - Sets:axis_ticks_length_y_right: How long the ticks of the y axis right of the panels are.:line(term/0) - Sets:axis_line_y_right: The line of the y axis right of the panels.:minor_ticks(term/0) - Sets:axis_minor_ticks_y_right: The minor ticks of the y axis right of the panels.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_y_right: How long the minor ticks of the y axis right of the panels are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis_right(plot, title: [colour: "dimgray"]) == ...> Giggly.Plot.theme(plot, axis_title_y_right: [colour: "dimgray"]) true
@spec theme_sub_axis_top(t(), keyword()) :: t()
@spec theme_sub_axis_top(theme(), keyword()) :: theme()
@spec theme_sub_axis_top(keyword(), []) :: theme()
Sets the elements of the x axis above the panels by shorter names: text: sets
axis_text_x_top.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_x_top: The title of the x axis above the panels.:text(term/0) - Sets:axis_text_x_top: The tick labels of the x axis above the panels.:ticks(term/0) - Sets:axis_ticks_x_top: The ticks of the x axis above the panels.:ticks_length(term/0) - Sets:axis_ticks_length_x_top: How long the ticks of the x axis above the panels are.:line(term/0) - Sets:axis_line_x_top: The line of the x axis above the panels.:minor_ticks(term/0) - Sets:axis_minor_ticks_x_top: The minor ticks of the x axis above the panels.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_x_top: How long the minor ticks of the x axis above the panels are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis_top(plot, text: [face: :bold]) == ...> Giggly.Plot.theme(plot, axis_text_x_top: [face: :bold]) true
@spec theme_sub_axis_x(t(), keyword()) :: t()
@spec theme_sub_axis_x(theme(), keyword()) :: theme()
@spec theme_sub_axis_x(keyword(), []) :: theme()
Sets the elements of both x axes, below and above the panels, by shorter names: text: sets
axis_text_x.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_x: The x axis's title.:text(term/0) - Sets:axis_text_x: The x axis's tick labels.:ticks(term/0) - Sets:axis_ticks_x: The x axis's ticks.:ticks_length(term/0) - Sets:axis_ticks_length_x: How long the x axis's ticks are.:line(term/0) - Sets:axis_line_x: The x axis's line.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_x: How long the x axis's minor ticks are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis_x(plot, title: :none, line: [colour: "black"]) == ...> Giggly.Plot.theme(plot, axis_title_x: :none, axis_line_x: [colour: "black"]) true
@spec theme_sub_axis_y(t(), keyword()) :: t()
@spec theme_sub_axis_y(theme(), keyword()) :: theme()
@spec theme_sub_axis_y(keyword(), []) :: theme()
Sets the elements of both y axes, left and right of the panels, by shorter names: text: sets
axis_text_y.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:title(term/0) - Sets:axis_title_y: The y axis's title.:text(term/0) - Sets:axis_text_y: The y axis's tick labels.:ticks(term/0) - Sets:axis_ticks_y: The y axis's ticks.:ticks_length(term/0) - Sets:axis_ticks_length_y: How long the y axis's ticks are.:line(term/0) - Sets:axis_line_y: The y axis's line.:minor_ticks_length(term/0) - Sets:axis_minor_ticks_length_y: How long the y axis's minor ticks are.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_axis_y(plot, text: [angle: 90], ticks: :none) == ...> Giggly.Plot.theme(plot, axis_text_y: [angle: 90], axis_ticks_y: :none) true
@spec theme_sub_legend(t(), keyword()) :: t()
@spec theme_sub_legend(theme(), keyword()) :: theme()
@spec theme_sub_legend(keyword(), []) :: theme()
Sets the elements of the legends by shorter names: key_size: sets legend_key_size.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:text(term/0) - Sets:legend_text: The legends' labels.:text_position(term/0) - Sets:legend_text_position: Which side of a legend's keys its labels go on::top,:right,:bottomor:left; a colour bar's or colour steps' along the bar alone, either side of one running up and above or below one running across. Right of a legend's keys, and of a bar running up, and below a bar running across, unless given.:title(term/0) - Sets:legend_title: The legends' titles.:title_position(term/0) - Sets:legend_title_position: Which side of a legend's keys its title goes on::top,:right,:bottomor:left; above keys running down and left of keys running across unless given.:background(term/0) - Sets:legend_background: Each legend's background.:frame(term/0) - Sets:legend_frame: The border round a colour bar's bar, and colour steps', never filled; none unless set.:ticks(term/0) - Sets:legend_ticks: A colour bar's ticks, colour steps' and a binned legend's.:ticks_length(term/0) - Sets:legend_ticks_length: How far a colour bar's or colour steps' ticks reach into the bar.:axis_line(term/0) - Sets:legend_axis_line: The line along a legend's axis, a binned legend's.:spacing(term/0) - Sets:legend_spacing: The space between legends.:spacing_x(term/0) - Sets:legend_spacing_x: The space between a legend and the next beside it.:spacing_y(term/0) - Sets:legend_spacing_y: The space between a legend and the next below it.:margin(term/0) - Sets:legend_margin: The margin inside each legend's edge.:key(term/0) - Sets:legend_key: The background of each legend key.:key_size(term/0) - Sets:legend_key_size: How big each legend key is.:key_height(term/0) - Sets:legend_key_height: How tall each legend key is.:key_width(term/0) - Sets:legend_key_width: How wide each legend key is.:key_spacing(term/0) - Sets:legend_key_spacing: The space between a legend's keys and its labels, and below its title.:key_spacing_x(term/0) - Sets:legend_key_spacing_x: The space between a legend's columns of keys.:key_spacing_y(term/0) - Sets:legend_key_spacing_y: The space between a legend's rows of keys; none in a legend running down unless set.:key_justification(term/0) - Sets:legend_key_justification: Where a legend key smaller than its row and column sits in them, as:legend_justificationtakes; filling them when not given.:byrow(term/0) - Sets:legend_byrow: Whether a legend's keys fill its rows first,true, or its columns,false.:position(term/0) - Sets:legend_position: Where the legends go::right,:left,:topor:bottom, beside the panels on that side,:inside, over them, or:none, for no legends.:direction(term/0) - Sets:legend_direction: Which way each legend's keys run::horizontalor:vertical; across above or below the panels and down elsewhere unless given.:location(term/0) - Sets:legend_location: What legends beside the panels line up with::panel, the panels, or:plot, the axes and their titles too.:position_inside(term/0) - Sets:legend_position_inside: Where the legends' box goes when they are inside the panels:{x, y}, each a share of the panels' width or height from their left or bottom; at its justification unless given.:justification(term/0) - Sets:legend_justification: Which point of the legends' box is placed where it goes::center, a side (:left,:right,:top,:bottom), or{horizontal, vertical}, each a share of the box's width or height or:left,:centeror:rightacross and:bottom,:centeror:topup; beside the panels, the same point of the room beside them.:justification_top(term/0) - Sets:legend_justification_top: The justification of legends above the panels.:justification_bottom(term/0) - Sets:legend_justification_bottom: The justification of legends below the panels.:justification_left(term/0) - Sets:legend_justification_left: The justification of legends left of the panels.:justification_right(term/0) - Sets:legend_justification_right: The justification of legends right of the panels.:justification_inside(term/0) - Sets:legend_justification_inside: The justification of legends inside the panels.:box(term/0) - Sets:legend_box: How several legends are arranged::horizontal, side by side, or:vertical, one above another; side by side above or below the panels and one above another elsewhere unless given.:box_just(term/0) - Sets:legend_box_just: Which point of each legend is placed at the same point of its room in the box: as:legend_justificationtakes, by name alone; at the box's top, centred across above or below the panels and at its left elsewhere, unless given.:box_margin(term/0) - Sets:legend_box_margin: The margin inside the legends' box.:box_background(term/0) - Sets:legend_box_background: The background of the legends' box, over its margin too, drawn as its own setting gives it: what that leaves unset is the drawing's default, a white fill and a solid black border 0.75 points wide, never:rect's.:box_spacing(term/0) - Sets:legend_box_spacing: The space between the panels and the legends.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_legend(plot, position: :bottom, key_size: {1, :cm}) == ...> Giggly.Plot.theme(plot, legend_position: :bottom, legend_key_size: {1, :cm}) true
@spec theme_sub_panel(t(), keyword()) :: t()
@spec theme_sub_panel(theme(), keyword()) :: theme()
@spec theme_sub_panel(keyword(), []) :: theme()
Sets the elements of the panels by shorter names: grid_minor: sets panel_grid_minor.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:background(term/0) - Sets:panel_background: The panels' background, under the layers.:border(term/0) - Sets:panel_border: The panels' border, drawn over the layers and never filled.:widths(term/0) - Sets:panel_widths: How wide the panels are: one length, the width of them all from the first's left edge to the last's right, the space and axes between them included, shared as their scales share it; or a list of lengths, each column's in turn, begun again when it runs out.:none, the default, leaves them what the drawing's space leaves them. A single panel keeping its shape is as tall as its width and shape make it unlesspanel_heightssays otherwise; several keep it no longer, as tall as the drawing's space leaves them.:heights(term/0) - Sets:panel_heights: How tall the panels are: one length, the height of them all from the first's top edge to the last's bottom, the space, axes and strips between them included, shared as their scales share it; or a list of lengths, each row's in turn, begun again when it runs out.:none, the default, leaves them what the drawing's space leaves them. A single panel keeping its shape is as wide as its height and shape make it unlesspanel_widthssays otherwise; several keep it no longer, as wide as the drawing's space leaves them.:spacing(term/0) - Sets:panel_spacing: The space between panels.:spacing_x(term/0) - Sets:panel_spacing_x: The space between panels side by side.:spacing_y(term/0) - Sets:panel_spacing_y: The space between panels one above another.:grid(term/0) - Sets:panel_grid: The panels' grid lines.:grid_major(term/0) - Sets:panel_grid_major: The grid lines at the axes' breaks.:grid_minor(term/0) - Sets:panel_grid_minor: The grid lines between the axes' breaks.:grid_major_x(term/0) - Sets:panel_grid_major_x: The grid lines at the x axis's breaks.:grid_major_y(term/0) - Sets:panel_grid_major_y: The grid lines at the y axis's breaks.:grid_minor_x(term/0) - Sets:panel_grid_minor_x: The grid lines between the x axis's breaks.:grid_minor_y(term/0) - Sets:panel_grid_minor_y: The grid lines between the y axis's breaks.:ontop(term/0) - Sets:panel_ontop: Whether the panels' background and grid lines are drawn over the layers,true, or under them,false.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_panel(plot, background: [fill: "white"], grid_minor: :none) == ...> Giggly.Plot.theme(plot, panel_background: [fill: "white"], panel_grid_minor: :none) true
@spec theme_sub_plot(t(), keyword()) :: t()
@spec theme_sub_plot(theme(), keyword()) :: theme()
@spec theme_sub_plot(keyword(), []) :: theme()
Sets the elements of the whole plot by shorter names: title: sets plot_title.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:background(term/0) - Sets:plot_background: The background of the whole plot.:title(term/0) - Sets:plot_title: The plot's title.:title_position(term/0) - Sets:plot_title_position: What the plot's title and subtitle line up with::panel, the panels, or:plot, everything inside the margin and the tag.:subtitle(term/0) - Sets:plot_subtitle: The plot's subtitle.:caption(term/0) - Sets:plot_caption: The plot's caption.:caption_position(term/0) - Sets:plot_caption_position: What the plot's caption lines up with::panel, the panels, or:plot, everything inside the margin and the tag.:tag(term/0) - Sets:plot_tag: The plot's tag.:tag_position(term/0) - Sets:plot_tag_position: Where the plot's tag goes: a corner or a side,:topleft,:top,:topright,:left,:right,:bottomleft,:bottomor:bottomright, or a point{x, y}, each a share of what it is placed in, from the left and from the bottom.:tag_location(term/0) - Sets:plot_tag_location: What the plot's tag is placed in::margin, a row or column of its own between the margin and everything else,:plot, everything inside the margin, or:panel, the panels, the last two taking no room. Unset, it is:plotfor a point and:marginfor a corner or a side; a point cannot be placed in the margin.:margin(term/0) - Sets:plot_margin: The margin round the whole plot.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_plot(plot, title: [face: :bold], margin: 10) == ...> Giggly.Plot.theme(plot, plot_title: [face: :bold], plot_margin: 10) true
@spec theme_sub_strip(t(), keyword()) :: t()
@spec theme_sub_strip(theme(), keyword()) :: theme()
@spec theme_sub_strip(keyword(), []) :: theme()
Sets the elements of the facets' strips by shorter names: text_x: sets strip_text_x.
It is theme/2 with each name written out in full, so it lays its elements over the plot's
theme as theme/2 does, or over a theme given in the plot's place, or, given its settings
alone, returns a theme of them, and each takes what theme/2 takes for that element, :none
removing a line, a rectangle or a text.
Raises NimbleOptions.ValidationError for a name it does not know, or for a value its element
cannot take, naming the element, and ArgumentError for a name or a property given twice.
Options
:background(term/0) - Sets:strip_background: The strips' background.:background_x(term/0) - Sets:strip_background_x: The background of the strips above or below panels.:background_y(term/0) - Sets:strip_background_y: The background of the strips left or right of panels.:clip(term/0) - Sets:strip_clip: Whether each strip's background and label are cut off at its edges,:on, or not,:offor:inherit.:placement(term/0) - Sets:strip_placement: Whether strips beside axes sit between the panel and the axis,:inside, or beyond the axis,:outside;:insideunless given.:text(term/0) - Sets:strip_text: The strips' labels.:text_x(term/0) - Sets:strip_text_x: The labels of the strips above or below panels.:text_x_bottom(term/0) - Sets:strip_text_x_bottom: The labels of the strips below panels.:text_x_top(term/0) - Sets:strip_text_x_top: The labels of the strips above panels.:text_y(term/0) - Sets:strip_text_y: The labels of the strips left or right of panels.:text_y_left(term/0) - Sets:strip_text_y_left: The labels of the strips left of panels.:text_y_right(term/0) - Sets:strip_text_y_right: The labels of the strips right of panels.:switch_pad_grid(term/0) - Sets:strip_switch_pad_grid: The space between afacet_grid/2strip placed outside the axes and the axes, on a side with an axis.:switch_pad_wrap(term/0) - Sets:strip_switch_pad_wrap: The space between afacet_wrap/3strip placed outside the axes and the axes, in each row or column of panels with an axis on that side.iex> plot = Giggly.Plot.new(%{"wt" => [2.62], "mpg" => [21.0]}, %{x: :wt, y: :mpg}) iex> Giggly.Plot.theme_sub_strip(plot, background: :none, placement: :outside) == ...> Giggly.Plot.theme(plot, strip_background: :none, strip_placement: :outside) true
Draws as theme_bw/2 does but with no grid lines and no margin inside a legend, and sets a
radial panel's radius labels as the y axis's: a theme meant for comparing drawings, which
should not change from one version to the next.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_test() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> {svg =~ "stroke: #333333", svg =~ "#EBEBEB"} {true, false}
Draws nothing but the marks, the legends, the strips' labels and the plot's titles: no axes, grid lines or backgrounds, on a transparent plot with no margin round it. With no lines and no borders to draw, only its base size changes what it draws.
Given a plot, it replaces the plot's theme whole, dropping the settings theme/2 laid over the
one before; given its options alone, it returns the theme, to be kept and given to plots with
theme/2.
Each later theme/2 call is laid over it in turn: its properties replace only those they give,
and an element set after a removal of the same element replaces the complete theme's element
whole, inheriting what it leaves unset from its parent.
Raises NimbleOptions.ValidationError for an option it does not know or a size it cannot use,
and ArgumentError for an option given twice.
Options
:base_size- How big its text is, in points, 0 or more: every text's size is a share of it, and the space between parts of the plot half of it. 11 unless given.:base_line_size- How wide its lines are, in millimetres, 0 or more.base_size / 22unless given.:base_rect_size- How wide its rectangles' borders are, in millimetres, 0 or more.base_size / 22unless given.:base_family(String.t/0) - The font its text and its layers' text are drawn in, by name, astheme/2'sfamily:takes one."", the default sans-serif, unless given.:header_family(String.t/0) - The font its titles are drawn in, by name: the axes' and the legends' titles and the plot's title. The base family unless given.:ink- The colour its lines, borders and text are drawn in, and its layers' marks, a CSS colour, which may have an alpha of its own; each grey it draws is the ink mixed toward the paper. Black unless given.:paper- The colour its backgrounds are filled with, and the greys mixed toward from the ink, asink:takes one. White unless given,theme_void/2's the ink with no alpha.:accent- The colour a smooth, a contour and a quantile line are drawn in, asink:takes one.#3366FFunless given.iex> svg = ...> %{"wt" => [2.62, 2.875], "mpg" => [21.0, 22.8]} ...> |> Giggly.Plot.new(%{x: :wt, y: :mpg}) ...> |> Giggly.Plot.geom_point() ...> |> Giggly.Plot.theme_void() ...> |> Giggly.to_svg() ...> |> IO.iodata_to_binary() iex> length(Regex.scan(~r/<text|<polyline/, svg)) 0
Gives the plot a discrete x scale showing values, in the order given, replacing any x scale it
had, as scale_x_discrete(plot, limits: values) does.
iex> plot =
...> %{"cut" => ["Fair", "Good", "Ideal"], "price" => [3000, 4000, 3500]}
...> |> Giggly.Plot.new(%{x: :cut, y: :price})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.xlim(["Ideal", "Fair"])
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[2, nil, 1]
Gives the plot an x scale from low to high, replacing any x scale it had: a continuous scale
for numbers, as scale_x_continuous(plot, limits: {low, high}) gives, a date scale for dates,
as scale_x_date(plot, limits: {low, high}) gives, or a date-time scale for date-times, as
scale_x_datetime(plot, limits: {low, high}) gives; nil leaves an end to the data. Numbers
given high to low run the axis from high to low, as transform: :reverse runs it, each value
placed at its negation; dates and date-times given so name the same axis as low to high. A
discrete axis's limits are a list of its values, which xlim/2 takes. Two times of day are
refused: scale_x_time(plot, limits: {low, high}) takes them.
iex> plot =
...> %{"wt" => [1.5, 2.6, 3.4], "mpg" => [30.4, 21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.xlim(nil, 4)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[1.5, 2.6, 3.4]A reversed axis:
iex> plot =
...> %{"mpg" => [21.0, 22.8, 18.7], "wt" => [2.62, 2.32, 3.44]}
...> |> Giggly.Plot.new(%{x: :mpg, y: :wt})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.xlim(20, 15)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[nil, nil, -18.7]Dates:
iex> plot =
...> %{"day" => [~D[2024-01-01], ~D[2024-01-11]], "value" => [1, 2]}
...> |> Giggly.Plot.new(%{x: :day, y: :value})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.xlim(~D[2024-01-05], nil)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:x)
[nil, 19733.0]
Gives the plot a discrete y scale showing values, in the order given, replacing any y scale it
had, as xlim/2 gives an x scale.
iex> plot =
...> %{"price" => [3000, 4000, 3500], "cut" => ["Fair", "Good", "Ideal"]}
...> |> Giggly.Plot.new(%{x: :price, y: :cut})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.ylim(["Good", "Fair"])
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y)
[2, 1, nil]
Gives the plot a y scale from low to high, replacing any y scale it had, as xlim/3 gives
an x scale.
iex> plot =
...> %{"wt" => [1.5, 2.6, 3.4], "mpg" => [30.4, 21.0, 18.7]}
...> |> Giggly.Plot.new(%{x: :wt, y: :mpg})
...> |> Giggly.Plot.geom_point()
...> |> Giggly.Plot.ylim(15, 25)
iex> plot |> Giggly.layer_data() |> Giggly.DataFrame.pull(:y)
[nil, 21.0, 18.7]