API
AlgebraOfGraphics.AxisEntries Type
AxisEntries(axis::Union{Axis, Nothing}, entries::Vector{Entry}, categoricalscales, continuousscales)Define all ingredients to make plots on an axis. Each categorical scale should be a CategoricalScale, and each continuous scale should be a ContinuousScale.
AlgebraOfGraphics.Choropleth Type
Choropleth is the plot type associated with plotting function choropleth. Check the docstring for choropleth for further information.
AlgebraOfGraphics.Entry Type
Entry(plottype::PlotType, positional::Arguments, named::NamedArguments)Define plottype as well as positional and named arguments for a single plot.
sourceAlgebraOfGraphics.Layer Type
Layer(transformation, data, positional::AbstractVector, named::AbstractDictionary)Algebraic object encoding a single layer of a visualization. It is composed of a dataset, positional and named arguments, as well as a transformation to be applied to those. Layer objects can be multiplied, yielding a novel Layer object, or added, yielding a Layers object.
AlgebraOfGraphics.Layers Type
Layers(layers::Vector{Layer})Algebraic object encoding a list of Layer objects. Layers objects can be added or multiplied, yielding a novel Layers object.
AlgebraOfGraphics.LongPoly Type
LongPoly is the plot type associated with plotting function longpoly. Check the docstring for longpoly for further information.
AlgebraOfGraphics.ProcessedLayer Method
ProcessedLayer(l::Layer)Process a Layer and return the resulting ProcessedLayer.
Note that this method should not be used anymore as processing a Layer can now potentially return multiple ProcessedLayer objects. Therefore, you should use the plural form ProcessedLayers(layer).
AlgebraOfGraphics.ProcessedLayers Type
ProcessedLayers(layers::Vector{ProcessedLayer})Object encoding a list of ProcessedLayer objects. ProcessedLayers objects are the output of the processing pipeline and can be drawn without further processing.
AlgebraOfGraphics.ProcessedLayers Method
ProcessedLayers(layer::Layer)Output of processing a layer. Each ProcessedLayer encodes
plot type,
grouping arguments,
positional and named arguments for the plot,
labeling information,
visual attributes.
AlgebraOfGraphics.choropleth Function
choropleth(geometries; transformation, attributes...)Choropleth map, where regions are defined by geometries. Use transformation to transform coordinates (see Proj.jl for more information).
Warning
The transformation keyword argument is experimental and could be deprecated (even in a non-breaking release) in favor of a different syntax.
Plot type
The plot type alias for the choropleth function is Choropleth.
Attributes
alpha = 1.0 — The alpha value of the colormap or color attribute. Multiple alphas like in plot(alpha=0.2, color=(:red, 0.5), will get multiplied.
clip_planes = @inherit clip_planes automatic — Clip planes offer a way to do clipping in 3D space. You can set a Vector of up to 8 Plane3f planes here, behind which plots will be clipped (i.e. become invisible). By default clip planes are inherited from the parent plot or scene. You can remove parent clip_planes by passing Plane3f[].
color = @inherit patchcolor — Sets the color of the poly. Can be a Vector{<:Colorant} for per vertex colors or a single Colorant. A Matrix{<:Colorant} can be used to color the mesh with a texture, which requires the mesh to contain texture coordinates. Vector or Matrices of numbers can be used as well, which will use the colormap arguments to map the numbers to colors. One can also use a <: AbstractPattern, to cover the poly with a regular pattern, e.g. for hatching.
colormap = @inherit colormap :viridis — Sets the colormap that is sampled for numeric colors. PlotUtils.cgrad(...), Makie.Reverse(any_colormap) can be used as well, or any symbol from ColorBrewer or PlotUtils. To see all available color gradients, you can call Makie.available_gradients().
colorrange = automatic — The values representing the start and end points of colormap.
colorscale = identity — The color transform function. Can be any function, but only works well together with Colorbar for identity, log, log2, log10, sqrt, logit, Makie.pseudolog10, Makie.Symlog10, Makie.AsinhScale, Makie.SinhScale, Makie.LogScale, Makie.LuptonAsinhScale, and Makie.PowerScale.
cycle = [:color => :patchcolor] — Sets which attributes to cycle when creating multiple plots. The values to cycle through are defined by the parent Theme. Multiple cycled attributes can be set by passing a vector. Elements can
directly refer to a cycled attribute, e.g.
:colormap a cycled attribute to a palette attribute, e.g.
:linecolor => :colormap multiple cycled attributes to a palette attribute, e.g.
[:linecolor, :markercolor] => :color
depth_shift = 0.0 — Adjusts the depth value of a plot after all other transformations, i.e. in clip space, where -1 <= depth <= 1. This only applies to GLMakie and WGLMakie and can be used to adjust render order (like a tunable overdraw).
fxaa = true — Adjusts whether the plot is rendered with fxaa (fast approximate anti-aliasing, GLMakie only). Note that some plots implement a better native anti-aliasing solution (scatter, text, lines). For them fxaa = true generally lowers quality. Plots that show smoothly interpolated data (e.g. image, surface) may also degrade in quality as fxaa = true can cause blurring.
highclip = automatic — The color for any value above the colorrange.
inspectable = @inherit inspectable — Sets whether this plot should be seen by DataInspector. The default depends on the theme of the parent scene.
inspector_clear = automatic — Sets a callback function (inspector, plot) -> ... for cleaning up custom indicators in DataInspector.
inspector_hover = automatic — Sets a callback function (inspector, plot, index) -> ... which replaces the default show_data methods.
inspector_label = automatic — Sets a callback function (plot, index, position) -> string which replaces the default label generated by DataInspector.
joinstyle = @inherit joinstyle — Controls the rendering of outline corners. Options are :miter for sharp corners, :bevel for "cut off" corners, and :round for rounded corners. If the corner angle is below miter_limit, :miter is equivalent to :bevel to avoid long spikes.
linecap = @inherit linecap — Sets the type of line cap used for outlines. Options are :butt (flat without extrusion), :square (flat with half a linewidth extrusion) or :round.
linestyle = nothing — Sets the dash pattern of the line. Options are :solid (equivalent to nothing), :dot, :dash, :dashdot and :dashdotdot. These can also be given in a tuple with a gap style modifier, either :normal, :dense or :loose. For example, (:dot, :loose) or (:dashdot, :dense).
For custom patterns have a look at Makie.Linestyle.
lowclip = automatic — The color for any value below the colorrange.
miter_limit = @inherit miter_limit — Sets the minimum inner join angle below which miter line joins truncate. See also Makie.miter_distance_to_angle.
model = automatic — Sets a model matrix for the plot. This overrides adjustments made with translate!, rotate! and scale!.
nan_color = :transparent — The color for NaN values.
overdraw = false — Controls if the plot will draw over other plots. This specifically means ignoring depth checks in GL backends
shading = false — Controls whether lights affect the polygon.
space = :data — Sets the transformation space for box encompassing the plot. See Makie.spaces() for possible inputs.
ssao = false — Adjusts whether the plot is rendered with ssao (screen space ambient occlusion). Note that this only makes sense in 3D plots and is only applicable with fxaa = true.
stroke_depth_shift = -1.0e-5 — Depth shift of stroke plot. This is useful to avoid z-fighting between the stroke and the fill.
strokecolor = @inherit patchstrokecolor — Sets the color of the outline around a marker.
strokecolormap = @inherit colormap — Sets the colormap that is sampled for numeric colors.
strokewidth = @inherit patchstrokewidth — Sets the width of the outline.
transformation = :automatic — Controls the inheritance or directly sets the transformations of a plot. Transformations include the transform function and model matrix as generated by translate!(...), scale!(...) and rotate!(...). They can be set directly by passing a Transformation() object or inherited from the parent plot or scene. Inheritance options include:
:automatic: Inherit transformations if the parent and childspaceis compatible:inherit: Inherit transformations:inherit_model: Inherit only model transformations:inherit_transform_func: Inherit only the transform function:nothing: Inherit neither, fully disconnecting the child's transformations from the parent
Another option is to pass arguments to the transform!() function which then get applied to the plot. For example transformation = (:xz, 1.0) which rotates the xy plane to the xz plane and translates by 1.0. For this inheritance defaults to :automatic but can also be set through e.g. (:nothing, (:xz, 1.0)).
transparency = false — Adjusts how the plot deals with transparency. In GLMakie transparency = true results in using Order Independent Transparency.
visible = true — Controls whether the plot gets rendered or not.
AlgebraOfGraphics.choropleth! Function
choropleth! is the mutating variant of plotting function choropleth. Check the docstring for choropleth for further information.
AlgebraOfGraphics.clipped Method
clipped(palette; high = nothing, low = nothing)Wrap a color palette such that, when used with a categorical scale made of ordered Bins, the end bins get the clip colors if they extend to plus/minus infinity. The inner bins then pick their colors from the wrapped palette.
AlgebraOfGraphics.colorbar! Method
colorbar!(figpos, grid; kwargs...)::Vector{Colorbar}Compute zero or more colorbars for grid (which should be the output of draw!) and draw them in a nested GridLayout in position figpos. One colorbar will be drawn for each applicable scale. Attributes allowed in kwargs are the same as MakieLayout.Colorbar.
Note
Before AlgebraOfGraphics v0.10, this function returned Union{Nothing,Colorbar} because multiple colorbars in a single figure were not supported. The name of the function was kept singular colorbar to be less breaking.
AlgebraOfGraphics.contours Method
contours(; levels=5, kwargs...)Create contour lines over the grid spanned over x and y by args 1 and 2 in the mapping, with height values z passed via arg 3.
You can pass the number of levels as an integer or a vector of levels. The levels are calculated across the whole z data if they are specified as an integer.
Note that visual(Contour) only works in a limited way with AlgebraOfGraphics since version 0.7, because the internal calculations it does are not compatible with the scale system. With visual(Contour), you can only have categorically-colored contours (for example to visualize contours of multiple categories). Alternatively, if you set the colormap attribute, you can get continuously-colored contours but the levels will not be known to AlgebraOfGraphics, so they won't be synchronized across facets and there will not be a colorbar.
All other keyword arguments are forwarded as attributes to the underlying Contour plot.
AlgebraOfGraphics.data Method
data(table)Create a Layer with its data field set to a table-like object.
There are no type restrictions on this object, as long as it respects the Tables interface. In particular, any one of these formats should work out of the box.
To create a fully specified layer, the layer created with data needs to be multiplied with the output of mapping.
spec = data(...) * mapping(...)AlgebraOfGraphics.datetimeticks Method
datetimeticks(datetimes::AbstractVector{<:TimeType}, labels::AbstractVector{<:AbstractString})Generate ticks matching datetimes to the corresponding labels. The result can be passed to xticks, yticks, or zticks.
AlgebraOfGraphics.datetimeticks Method
datetimeticks(f, datetimes::AbstractVector{<:TimeType})Compute ticks for the given datetimes using a formatting function f. The result can be passed to xticks, yticks, or zticks.
AlgebraOfGraphics.density Method
density(; datalimits=automatic, kernel=automatic, bandwidth=automatic, npoints=200, direction=automatic)Fit a kernel density estimation of data.
Here, datalimits specifies the range for which the density should be calculated (it defaults to the extrema of the whole data). The keyword argument datalimits can be a tuple of two values, e.g. datalimits=(0, 10), or a function to be applied group by group, e.g. datalimits=extrema. The keyword arguments kernel and bandwidth are forwarded to KernelDensity.kde. npoints is the number of points used by Makie to draw the line
Weighted data is supported via the keyword weights (passed to mapping).
For 1D, returns two layers, a Band with label :area and a Lines with label :line which you can separately style using subvisual. The direction may be changed to vertical via direction = :y.
For 2D, returns a Heatmap and for 3D a Volume layer.
AlgebraOfGraphics.dims Method
dims(args...)Create a DimsSelector object which can be used in mapping to refer to the dimensions of the layer's shape.
Example:
mapping([:x1, :x2, :x3], col = dims(1))In the normal case where only single columns are referenced in mapping, the shape of the layer is (1,). If, for example, the first mapping entry, let's say for the X scale, is a column vector with three column selectors, like [:x1, :x2, :x3], the shape becomes (3,). If there's additionally a second mapping entry for the Y scale with four column selectors in a row vector, like [:y1 :y2 :y3 :y4], which by itself has shape (1, 4), the overall shape becomes (3, 4). This means that 3 x 4 = 12 combinations of columns will be plotted together as X and Y in the same axis.
The dims selector can now be used to create what can be thought of as a categorical scale with as many entries as the product of the sizes of the selected dimensions. For example, if we have our shape (3, 4) and add color = dims(1), the data will be colored in three different shades, one for each column selector in the first dimension (the three columns passed to the X scale). If we set color = dims(1, 2), there will be 12 different shades, one for each combination of X and Y. If we set color = dims(2), there will be four different shades, one for each Y column.
With wide input data, it often makes sense to put each column into its own facet, in order not to overcrowd the visual space. Therefore, a common setting in the mapping in such scenarios could be row = dims(1), col = dims(2), for example.
AlgebraOfGraphics.direct Method
direct(x)Return DirectData(x) which marks x for direct use in a mapping that's used with a table-like data source. As a result, x will be used directly as data, without lookup in the table. If x is not an AbstractArray, it will be expanded like fill(x, n) where n is the number of rows in the data source.
AlgebraOfGraphics.draw Function
draw(d, scales::Scales = scales(); [axis, figure, facet, legend, colorbar])Draw a AlgebraOfGraphics.AbstractDrawable object d. In practice, d will often be a Layer or Layers. Scale options can be passed as an optional second argument. The output can be customized by passing named tuples or dictionaries with settings via the axis, figure, facet, legend or colorbar keywords. Legend and colorbar are drawn automatically unless show = false is passed to the keyword arguments of either legend or colorbar.
For finer control, use draw!, legend!, and colorbar! independently.
Figure options
AlgebraOfGraphics accepts the following special keywords under the figure keyword, the remaining attributes are forwarded to Makie's Figure constructor. The title, subtitle and footnotes arguments accept objects of any kind that Makie's Label or text function can handle, such as rich text.
titlesubtitletitlesize::Union{Nothing,Float64}subtitlesize::Union{Nothing,Float64}titlealign::Union{Nothing,Symbol}titlecolorsubtitlecolortitlefontsubtitlefonttitlelineheightsubtitlelineheightfootnotes::Union{Nothing,Vector{Any}}footnotesize::Union{Nothing,Float64}footnotefontfootnotecolorfootnotealignfootnotelineheight
Facet options
AlgebraOfGraphics accepts the following keywords under the facet keyword:
linkxaxes: Control x-axis linking. Valid values areautomatic,:all,:colwise,:minimal,:none,true, orfalse.linkyaxes: Control y-axis linking. Valid values areautomatic,:all,:rowwise,:minimal,:none,true, orfalse.hidexdecorations: Whether to hide x-axis decorations on inner panels. Valid values areautomatic,true, orfalse.hideydecorations: Whether to hide y-axis decorations on inner panels. Valid values areautomatic,true, orfalse.singlexlabel: Whether to show a single spanning x-axis label instead of labels on each panel. Valid values areautomatic,true, orfalse. Default isautomatic, which compacts labels when they are consistent across panels.singleylabel: Whether to show a single spanning y-axis label instead of labels on each panel. Valid values areautomatic,true, orfalse. Default isautomatic, which compacts labels when they are consistent across panels.
AlgebraOfGraphics.draw! Function
draw!(fig, d::AbstractDrawable, scales::Scales = scales(); [axis, facet])Draw a AlgebraOfGraphics.AbstractDrawable object d on fig. In practice, d will often be a Layer or Layers. fig can be a figure, a position in a layout, or an axis if d has no facet specification. The output can be customized by passing named tuples or dictionaries with settings via the axis or facet keywords.
AlgebraOfGraphics.draw Method
draw(p::Pagination, i::Int; kws...)Draw the ith element of Pagination p and return a FigureGrid. Keywords kws are passed to the underlying draw call.
You can retrieve the number of elements using length(p).
AlgebraOfGraphics.draw Method
draw(p::Pagination; kws...)Draw each element of Pagination p and return a Vector{FigureGrid}. Keywords kws are passed to the underlying draw calls.
AlgebraOfGraphics.expectation Method
expectation()Compute the expected value of the last argument conditioned on the preceding ones.
sourceAlgebraOfGraphics.filled_contours Method
filled_contours(; bands=automatic, levels=automatic)Create filled contours over the grid spanned over x and y by args 1 and 2 in the mapping, with height values z passed via arg 3.
You can pass either the number of bands to bands or pass a vector of levels (the boundaries of the bands) to levels, but not both. The number of bands when levels is passed is length(levels) - 1. The levels are calculated across the whole z data if the number of bands is specified. If neither levels nor bands are specified, the default is bands = 10.
Note that visual(Contourf) does not work with AlgebraOfGraphics since version 0.7, because the internal binning it does is not compatible with the scale system.
AlgebraOfGraphics.from_continuous Method
from_continuous(x; relative = true)Mark a colormap as continuous such that AlgebraOfGraphics will sample a categorical palette from start to end in n steps, and not by using the first n colors.
You could also use cgrad(colormap, n; categorical = true), however, this requires you to specify how many levels there are, which from_continuous detects automatically.
The relative option applies only when the datavalues of the palette are of type Bin. In this case, if relative = true, the continuous colormap is sampled at the relative midpoints of the bins, which means that neighboring bins that are smaller have more similar colors because their midpoints are closer together. If relative = false, the colormap is sampled evenly.
Example:
draw(scales(Color = (; palette = from_continuous(:viridis))))AlgebraOfGraphics.histogram Function
histogram(plottype::Type{<:Plot} = Plot{plot}; bins=automatic, datalimits=automatic, closed=:left, normalization=:none)Compute a histogram.
A plot type can be passed as the first argument controlling the type of plot the histogram is displayed as, e.g. histogram(Stairs) creates a stephist. The default plot type for 1-dimensional histograms is BarPlot, Heatmap for 2d, and Volume for 3d histograms.
The attribute bins can be an Integer, an AbstractVector (in particular, a range), or a Tuple of either integers or abstract vectors (useful for 2- or 3-dimensional histograms). When bins is an Integer, it denotes the approximate number of equal-width intervals used to compute the histogram. In that case, the range covered by the intervals is defined by datalimits (it defaults to the extrema of the whole data). The keyword argument datalimits can be a tuple of two values, e.g. datalimits=(0, 10), or a function to be applied group by group, e.g. datalimits=extrema. When bins is an AbstractVector, it denotes the intervals directly.
closed determines whether the the intervals are closed to the left or to the right.
The histogram can be normalized by setting normalization. Possible values are:
:pdf: Normalize by sum of weights and bin sizes. Resulting histogram has norm 1 and represents a PDF.:density: Normalize by bin sizes only. Resulting histogram represents count density of input and does not have norm 1.:probability: Normalize by sum of weights only. Resulting histogram represents the fraction of probability mass for each bin and does not have norm 1.:none: Do not normalize.
Weighted data is supported via the keyword weights (passed to mapping).
Note
Normalizations are computed withing groups. For example, in the case of normalization=:pdf, sum of weights within each group will be equal to 1.
AlgebraOfGraphics.legend! Method
legend!(figpos, grid; order = nothing, kwargs...)Compute legend for grid (which should be the output of draw!) and draw it in position figpos. All kwargs are forwarded to Makie's Legend constructor.
The order of scales represented in the legend can be changed with the order keyword. By default, legend sections are ordered the same as they appear in the plot specification. Assuming three scales Color, MarkerSize and custom exist in a spec, you can pass a vector to reorder them like [:MarkerSize, :custom, :Color], or merge multiple entries together with a nested vector like [[:MarkerSize, :custom], :Color], or give merged sections a title with the pair syntax [[:MarkerSize, :custom] => "Merged group", :Color].
AlgebraOfGraphics.linear Method
linear(; interval=automatic, level=0.95, dropcollinear=false, npoints=200)Compute a linear fit of y ~ 1 + x. An optional named mapping weights determines the weights. Use interval to specify what type of interval the shaded band should represent, for a given coverage level (the default 0.95 equates alpha = 0.05). Valid values of interval are :confidence, to delimit the uncertainty of the predicted relationship, and :prediction, to delimit estimated bounds for new data points. Use interval = nothing to only compute the line fit, without any uncertainty estimate. By default, this analysis errors on singular (collinear) data. To avoid that, it is possible to set dropcollinear=true. npoints is the number of points used by Makie to draw the shaded band.
Weighted data is supported via the keyword weights (passed to mapping).
This transformation creates two ProcessedLayers labelled :prediction and :ci, which can be styled separately with [subvisual](@ref).
AlgebraOfGraphics.longpoly Function
No docstring defined.
Plot type
The plot type alias for the longpoly function is LongPoly.
Attributes
color = @inherit patchcolor — No docs available.
strokecolor = @inherit patchstrokecolor — No docs available.
strokewidth = @inherit patchstrokewidth — No docs available.
AlgebraOfGraphics.longpoly! Function
longpoly! is the mutating variant of plotting function longpoly. Check the docstring for longpoly for further information.
AlgebraOfGraphics.mapping Method
mapping(positional...; named...)Create a Layer with positional and named selectors. These selectors will be translated into input data for the Makie plotting function or AlgebraOfGraphics analysis that is chosen to visualize the Layer.
A Layer created with mapping does not have a data source by default, you can add one by multiplying with the output of the data function.
The positional and named selectors of mapping are converted to actual input data for the plotting function that will be selected via visual. The translation from selector to data differs according to the data source.
Tabular data
When a mapping is combined with a data(tabular) where tabular is some Tables.jl-compatible object, each argument will be interpreted as a column selector. Additionally, it's allowed to specify columns outside of the dataset directly by wrapping the values in direct. The values can either be vectors that have to match the number of rows from the tabular data, or scalars that will be expanded as if they were a column filled with the same value.
mapping(
:x, # column named "x"
"a column"; # column named "a column"
color = 1, # first column
marker = direct("abc"), # a new column filled with the string "abc"
linestyle = direct(1:3), # a new column, length must match the table
)nothing
If no data is set, each entry of mapping should be an AbstractVector that specifies a column of data directly. Scalars like strings for example will be expanded as if they were a column filled with the same value. This is useful when a legend should be shown, but there's only one group.
mapping(
1:3, # a column with values 1 to 3
[4, 5, 6], # a column with values 4 to 6
color = "group 1", # a column with repeated value "group 1"
)Pregrouped
With data(Pregrouped()) * mapping(...) or the shortcut pregrouped(...), each element in mapping specifies input data directly, like with nothing. However, in this mode, data should be passed in pregrouped. Categorical variables should come as a vector of categories, while numerical variables should come as a vector of vectors of values, with as many inner vectors as there are groups in the categorical variables.
pregrouped(
[[1, 2, 3], [4, 5]], # two grouped vectors, of length 3 and 2
color = ["A", "B"] # a vector with two categorical group values
)AlgebraOfGraphics.nonnumeric Method
nonnumeric(x)Transform x into a non numeric type that is printed and sorted in the same way.
AlgebraOfGraphics.paginate Function
paginate(l, sc = scales(); layout=nothing, row=nothing, col=nothing)Paginate l, the Layer or Layers object created by an AlgebraOfGraphics spec, to create a Pagination object.
Info
The pages are created by internally starting with one big facet plot first which includes all the input data, and then splitting it into pages. All scales are fit to the full data, not just the data that is visible on a given page, so a color legend, for example, will show all the categories and not just the ones that happen to be visible on the current page. This behavior changed with version 0.9 - before, each page had separately fit scales. The old behavior had the drawback that palettes were not guaranteed to be consistent across pages, for example, the same category could have different colors on two separate pages.
The Pagination object can be passed to draw which will return a Vector{FigureGrid} rather than a single figure.
The keywords that limit the number of subplots on each page are the same that are used to specify facets in mapping:
layout: Maximum number of subplots in a wrapped linear layout.row: Maximum number of rows in a 2D layout.col: Maximum number of columns in a 2D layout.
Example
d = data((
x = rand(1000),
y = rand(1000),
group1 = rand(string.('a':'i'), 1000),
group2 = rand(string.('j':'r'), 1000),
))
layer_1 = d * mapping(:x, :y, layout = :group1) * visual(Scatter)
paginated_1 = paginate(layer_1, layout = 4)
figuregrids = draw(paginated_1)
layer_2 = d * mapping(:x, :y, row = :group1, col = :group2) * visual(Scatter)
paginated_2 = paginate(layer_2, row = 4, col = 3)
figuregrid = draw(paginated_2, 1) # draw only the first gridAlgebraOfGraphics.pregrouped Method
pregrouped(positional...; named...)Equivalent to data(Pregrouped()) * mapping(positional...; named...). Refer to mapping for more information.
AlgebraOfGraphics.presorted Method
presorted(x)Use within a pair expression in mapping to signal that a categorical column from the data source should be used in the original order and not automatically sorted.
Example:
# normally, categories would be sorted a, b, c but with `presorted`
# they stay in the order b, c, a
data((; some_column = ["b", "c", "a"])) * mapping(:some_column => presorted)AlgebraOfGraphics.renamer Method
renamer(arr::Union{AbstractArray, Tuple})Utility to rename a categorical variable, as in renamer([value1 => label1, value2 => label2]). The keys of all pairs should be all the unique values of the categorical variable and the values should be the corresponding labels. The order of arr is respected in the legend.
Examples
julia> r = renamer(["class 1" => "Class One", "class 2" => "Class Two"])
AlgebraOfGraphics.Renamer{Vector{String}, Vector{String}}(["class 1", "class 2"], ["Class One", "Class Two"])
julia> println(r("class 1"))
Class OneAlternatively, a sequence of pair arguments may be passed.
julia> r = renamer("class 1" => "Class One", "class 2" => "Class Two")
AlgebraOfGraphics.Renamer{Tuple{String, String}, Tuple{String, String}}(("class 1", "class 2"), ("Class One", "Class Two"))
julia> println(r("class 1"))
Class OneIf arr does not contain Pairs, elements of arr are assumed to be labels, and the unique values of the categorical variable are taken to be the indices of the array. This is particularly useful for dims mappings.
Examples
julia> r = renamer(["Class One", "Class Two"])
AlgebraOfGraphics.Renamer{Nothing, Vector{String}}(nothing, ["Class One", "Class Two"])
julia> println(r(2))
Class TwoAlgebraOfGraphics.scale Method
scale(id::Symbol)Create a ScaleID object that can be used in a mapping to assign a custom id to the mapped variable. This variable will then not be merged into the default scale for its aesthetic type, but instead be handled separately, leading to a separate legend entry.
AlgebraOfGraphics.scales Method
scales(; kwargs...)Create a Scales object containing properties for aesthetic scales that can be passed to draw and draw!. Each keyword should be the name of a scale in the spec that is being drawn. That can either be a default one like Color, Marker or LineStyle, or a custom scale name defined in a mapping using the scale function.
The values attached to the keywords must be dict-like, with Symbols as keys (such as NamedTuples).
AlgebraOfGraphics.set_aog_theme! Method
set_aog_theme!(; kwargs...)Set the current theme to a predefined and opinionated theme, as defined by the unexported internal function AlgebraOfGraphics.aog_theme.
To tweak the predefined theme, use the function Makie.update_theme!. See the example below on how to change, e.g., default fontsize, title, and markersize.
For more information about setting themes, see the Theming section of the Makie.jl docs.
Examples
julia> using CairoMakie, AlgebraOfGraphics
julia> set_aog_theme!() # Sets a prefedined theme
julia> update_theme!( # Tweaks the current theme
fontsize=30,
markersize=40,
Axis=(title="MyDefaultTitle",)
)AlgebraOfGraphics.show_aesthetics Method
show_aesthetics(T::Type{<:Makie.Plot})Show the aesthetic mappings defined for Makie plot type T. The aesthetic mappings show which named attributes can be used in mapping with a given set of positional arguments and which aesthetic types the arguments are mapped to.
Note
This function uses reflection on the method table to determine the applicable methods and it might not catch all applicable methods in all circumstances.
Example
show_aesthetics(Lines)
show_aesthetics(Errorbars)AlgebraOfGraphics.smooth Method
smooth(; span=0.75, degree=2, interval=:confidence, level=0.95, npoints=200)Fit a loess model. span is the degree of smoothing, typically in [0,1]. Smaller values result in smaller local context in fitting. degree is the polynomial degree used in the loess model. Use interval to specify what type of interval the shaded band should represent, for a given coverage level (the default 0.95 equates alpha = 0.05). Valid values of interval are :confidence (the default), to delimit the uncertainty of the predicted relationship. Use interval = nothing to only compute the line fit, without any uncertainty estimate. npoints is the number of points used by Makie to draw the line and shaded band.
This transformation creates two ProcessedLayers labelled :prediction and :ci, which can be styled separately with [subvisual](@ref).
AlgebraOfGraphics.sorter Method
sorter(ks)Utility to reorder a categorical variable, as in sorter(["low", "medium", "high"]). A vararg method sorter("low", "medium", "high") is also supported. ks should include all the unique values of the categorical variable. The order of ks is respected in the legend.
AlgebraOfGraphics.subvisual Function
subvisual(target, args...; kwargs...)Create a layer that works like visual(args...; kwargs...) but only applies to ProcessedLayers that match the target argument. This is intended for usage with transformation layers which create multiple layers themselves.
The types of target that can be used are:
Symbol: Can be used to pick processed layers by label if they have one. Transformations which create multiple processed layers should label them to facilitate this. For example, thelineartransformation creates a:predictionand a:cilayer.Type: e.g.BarPlotorScatter. Only layers with plot type<:Tare selected.
Example:
data(...) * mapping(...) * linear() * subvisual(:prediction, ...) * subvisual(:ci, ...)AlgebraOfGraphics.verbatim Method
verbatim(x)Signal that x should not be rescaled, but used in the plot as is.
AlgebraOfGraphics.visual Function
visual(plottype; attributes...)Create a Layer that will cause a plot spec multiplied with it to be visualized with plot type plottype, together with optional attributes.
The available plotting functions are documented here. Refer to plotting functions using upper CamelCase for visual's first argument (e.g. visual(Scatter), visual(BarPlot)). See the documentation of each plotting function to discover the available attributes. These attributes can be passed as additional keyword arguments to visual, or as part of the mapping you define.
The visual function can in principle be used for any plotting function that is defined using the @recipe macro from Makie. AlgebraOfGraphics just needs method definitions for aesthetic_mapping, which define what arguments of the plotting function map to which visual aesthetics. And for legend support, legend_elements must be overloaded for custom recipes as well, as Makie's default legend mechanism relies on instantiated plot objects, while AlgebraOfGraphics must go by the type and attributes alone.
To suppress a layer's legend contribution, pass legend = (; visible = false) as an attribute. This is an AlgebraOfGraphics-specific option that is intercepted before reaching Makie. Other entries in the legend named tuple are forwarded to Makie's LegendOverride mechanism as before.
data(...) * mapping(..., color = :group) * (visual(Scatter) + visual(Makie.Text, legend = (; visible = false)))Depending on its aesthetic_mapping, a plot type and its attributes may change certain semantics of a given data(...) * mapping(...) spec. For example, visual(BarPlot) will show mapping 1 on the x axis and 2 on the y axis, while visual(BarPlot, direction = :x) shows mapping 1 on y and 2 on x.
AlgebraOfGraphics.wrapped Method
wrapped(; cols = automatic, rows = automatic, by_col = false)Create an object that can be passed to the Layout scale palette which controls how many rows or columns are allowed at maximum in the wrapped layout. Only one of cols or rows may be set to an integer at the same time. If both are automatic, a squareish configuration is chosen. If by_col is to true, the layout is filled top to bottom first and then column by column.
AlgebraOfGraphics.zerolayer Method
zerolayer()Returns a Layers with an empty layer list which can act as a zero in the layer algebra.
layer * zerolayer() ~ zerolayer()
layer + zerolayer() ~ layerMakie types referenced in docstrings
Makie.Linestyle Type
Linestyle(value::Vector{<:Real})A type that can be used as value for the linestyle keyword argument of plotting functions to arbitrarily customize the linestyle.
The value is a vector specifying the boundaries of the dashes in the line. Values 1 and 2 demarcate the first dash, values 2 and 3 the first gap, and so on. This means that usually, a pattern should have an odd number of values so that there's always a gap after a dash.
Here's an example in ASCII code. If we specify [0, 3, 6, 11, 16] then we get the following pattern:
# 0 3 6 11 16 3 6 11
# --- ----- --- -----