Functions
Drawing functions
AlgebraOfGraphics.draw
โ Functiondraw(s; axis=NamedTuple(), figure=NamedTuple, palettes=NamedTuple())
Draw a AlgebraOfGraphics.Layer
or AlgebraOfGraphics.Layers
object s
. The output can be customized by giving axis attributes to axis
, figure attributes to figure
, or custom palettes to palettes
. Legend and colorbar are drawn automatically. For finer control, use draw!
, legend!
, and colorbar!
independently.
AlgebraOfGraphics.draw!
โ Functiondraw!(fig, s; axis=NamedTuple(), palettes=NamedTuple())
Draw a AlgebraOfGraphics.Layer
or AlgebraOfGraphics.Layers
object s
on fig
. fig
can be a figure, a position in a layout, or an axis if s
has no facet specification. The output can be customized by giving axis attributes to axis
or custom palettes to palettes
.
AlgebraOfGraphics.colorbar!
โ Functioncolorbar!(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.legend!
โ Functionlegend!(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
.
Mapping helpers
AlgebraOfGraphics.renamer
โ Functionrenamer(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 Pair
s, 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.sorter
โ Functionsorter(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.nonnumeric
โ Functionnonnumeric(x)
Transform x
into a non numeric type that is printed and sorted in the same way.
AlgebraOfGraphics.verbatim
โ Functionverbatim(x)
Signal that x
should not be rescaled, but used in the plot as is.
Ticks helpers
AlgebraOfGraphics.datetimeticks
โ Functiondatetimeticks(datetimes::AbstractVector{<:TimeType}, labels::AbstractVector{<:AbstractString})
Generate ticks matching datetimes
to the corresponding labels
. The result can be passed to xticks
, yticks
, or zticks
.
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
.
Internal functions
AlgebraOfGraphics.scientific_eltype
โ Functionscientific_eltype(v)
Determine whether v
should be treated as a continuous, geometrical, or categorical array.
AlgebraOfGraphics.scientific_type
โ Functionscientific_type(T::Type)
Determine whether T
represents a continuous, geometrical, or categorical variable.
AlgebraOfGraphics.plottypes_attributes
โ Functionplottypes_attributes(entries)
Return plottypes and relative attributes, as two vectors of the same length, for the given entries
.