AlgebraOfGraphics.AxisEntriesType
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.EntryType
Entry(plottype::PlotType, positional::Arguments, named::NamedArguments)

Define plottype as well as positional and named arguments for a single plot.

AlgebraOfGraphics.LayerType
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 AlgebraOfGraphics.Layers object.

AlgebraOfGraphics.ProcessedLayerMethod
ProcessedLayer(layer::Layer)

Output of processing a layer. A ProcessedLayer encodes

  • plot type,
  • grouping arguments,
  • positional and named arguments for the plot,
  • labeling information,
  • visual attributes.
AlgebraOfGraphics.aog_themeMethod
aog_theme(; fonts=[firasans("Medium"), firasans("Light")])

Return a NamedTuple of theme settings. Intended for internal use. The provided functionality is exposed to the user by the function set_aog_theme!.

AlgebraOfGraphics.choroplethMethod
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.

Attributes

Available attributes and their defaults for MakieCore.Plot{AlgebraOfGraphics.choropleth} are:

  alpha           1.0
  color           RGBA{Float32}(0.0f0,0.0f0,0.0f0,0.6f0)
  colormap        :viridis
  colorrange      MakieCore.Automatic()
  colorscale      identity
  cycle           [:color => :patchcolor]
  depth_shift     0.0f0
  highclip        MakieCore.Automatic()
  inspectable     true
  linestyle       "nothing"
  lowclip         MakieCore.Automatic()
  nan_color       :transparent
  overdraw        false
  shading         MakieCore.NoShading
  space           :data
  ssao            false
  strokecolor     :black
  strokecolormap  :viridis
  strokewidth     0
  transparency    false
  visible         true
AlgebraOfGraphics.colorbar!Method
colorbar!(figpos, grid; kwargs...)

Compute colorbar for grid (which should be the output of draw!) and draw it in position figpos. Attributes allowed in kwargs are the same as MakieLayout.Colorbar.

AlgebraOfGraphics.compute_attributesMethod
compute_attributes(pl::ProcessedLayer, categoricalscales, continuousscales_grid, continuousscales)

Process attributes of a ProcessedLayer. In particular,

  • remove AlgebraOfGraphics-specific layout attributes,
  • opt out of Makie cycling mechanism,
  • customize behavior of color (implementing alpha transparency),
  • customize behavior of bar width (default to one unit when not specified),
  • set correct colorrange.

Return computed attributes.

AlgebraOfGraphics.datetimeticksMethod
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.datetimeticksMethod
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.densityMethod
density(; datalimits=automatic, kernel=automatic, bandwidth=automatic, npoints=200)

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).

AlgebraOfGraphics.drawMethod
draw(p::PaginatedLayers, i::Int; kws...)

Draw the ith element of PaginatedLayers 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.drawMethod
draw(p::PaginatedLayers; kws...)

Draw each element of PaginatedLayers p and return a Vector{FigureGrid}. Keywords kws are passed to the underlying draw calls.

AlgebraOfGraphics.histogramMethod
histogram(; bins=automatic, datalimits=automatic, closed=:left, normalization=:none)

Compute a histogram.

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; kwargs...)

Compute legend for grid (which should be the output of draw!) and draw it in position figpos. Attributes allowed in kwargs are the same as MakieLayout.Legend.

AlgebraOfGraphics.linearMethod
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).

AlgebraOfGraphics.linesfillMethod
linesfill(xs, ys; lower, upper, attributes...)

Line plot with a shaded area between lower and upper. If lower and upper are not given, shaded area is between 0 and ys.

Attributes

Available attributes and their defaults for MakieCore.Plot{AlgebraOfGraphics.linesfill} are:

  color       :black
  colormap    :viridis
  colorrange  MakieCore.Automatic()
  fillalpha   0.15
  linestyle   "nothing"
  linewidth   1.5
  lower       MakieCore.Automatic()
  upper       MakieCore.Automatic()
AlgebraOfGraphics.paginateMethod
paginate(l; layout=nothing, row=nothing, col=nothing)

Paginate l, the Layer or Layers object created by an AlgebraOfGraphics spec, to create a PaginatedLayers object. This contains a vector of layers where each layer operates on a subset of the input data.

The PaginatedLayers 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 = 9)
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 grid
AlgebraOfGraphics.renamerMethod
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 One

Alternatively, 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 One

If 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 Two
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.smoothMethod
smooth(; span=0.75, degree=2, 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. npoints is the number of points used by Makie to draw the line

AlgebraOfGraphics.sorterMethod
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.