Scales
Scales, similarly to Statistics, apply a transformation to the original data, typically mapping one aesthetic to the same aesthetic, while retaining the original value. For example, the Scale.x_log10 aesthetic maps the x
aesthetic back to the x
aesthetic after applying a log10 transformation, but keeps track of the original value so that data points are properly identified.
Gadfly.Scale.color_identity
Gadfly.Scale.label
Gadfly.Scale.alpha_continuous
Gadfly.Scale.alpha_discrete
Gadfly.Scale.color_asinh
Gadfly.Scale.color_continuous
Gadfly.Scale.color_discrete_hue
Gadfly.Scale.color_discrete_manual
Gadfly.Scale.color_log
Gadfly.Scale.color_log10
Gadfly.Scale.color_log2
Gadfly.Scale.color_sqrt
Gadfly.Scale.group_discrete
Gadfly.Scale.lab_gradient
Gadfly.Scale.lab_gradient
Gadfly.Scale.lab_rainbow
Gadfly.Scale.lchabmix
Gadfly.Scale.linestyle_discrete
Gadfly.Scale.luv_rainbow
Gadfly.Scale.shape_discrete
Gadfly.Scale.shape_identity
Gadfly.Scale.size_area
Gadfly.Scale.size_continuous
Gadfly.Scale.size_discrete
Gadfly.Scale.size_discrete2
Gadfly.Scale.size_identity
Gadfly.Scale.size_radius
Gadfly.Scale.slope_continuous
Gadfly.Scale.weighted_color_mean
Gadfly.Scale.x_asinh
Gadfly.Scale.x_continuous
Gadfly.Scale.x_discrete
Gadfly.Scale.x_distribution
Gadfly.Scale.x_func
Gadfly.Scale.x_log
Gadfly.Scale.x_log10
Gadfly.Scale.x_log2
Gadfly.Scale.x_sqrt
Gadfly.Scale.xgroup
Gadfly.Scale.y_asinh
Gadfly.Scale.y_continuous
Gadfly.Scale.y_discrete
Gadfly.Scale.y_distribution
Gadfly.Scale.y_func
Gadfly.Scale.y_log
Gadfly.Scale.y_log10
Gadfly.Scale.y_log2
Gadfly.Scale.y_sqrt
Gadfly.Scale.ygroup
Gadfly.Scale.z_func
Gadfly.Scale.color_identity
— Typecolor_identity
Gadfly.Scale.label
— Typelabel
Gadfly.Scale.alpha_continuous
— Methodalpha_continuous[(; minvalue=0.0, maxvalue=1.0, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Rescale the data values between minvalue
and maxvalue
to opacity (alpha) values between 0 and 1.
Gadfly.Scale.alpha_discrete
— Methodalpha_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Similar to Scale.x_discrete
, except applied to the alpha
aesthetic. The alpha palette is set by Theme(alphas=[])
.
Gadfly.Scale.color_asinh
— Functioncolor_asinh[(; minvalue=nothing, maxvalue=nothing, colormap)]
Similar to Scale.color_continuous
, except that color
is asinh transformed.
Gadfly.Scale.color_continuous
— Functioncolor_continuous[(; minvalue=nothing, maxvalue=nothing, colormap)]
Create a continuous color scale by mapping the color
aesthetic to a Color
. minvalue
and maxvalue
specify the data values corresponding to the bottom and top of the color scale. colormap
is a function defined on the interval from 0 to 1 that returns a Color
. See also lab_gradient
.
Either input Stat.color_continuous
as an argument to plot
, or set continuous_color_scale
in a Theme.
See also color_log10
, color_log2
, color_log
, color_asinh
, and color_sqrt
.
Gadfly.Scale.color_discrete_hue
— Functioncolor_discrete_hue[(f; levels=nothing, order=nothing, preserve_order=true)]
Create a discrete color scale that maps the categorical levels in the color
aesthetic to Color
s. f
is a function that produces a vector of colors. levels
gives values for the scale. Order will be respected and anything in the data that's not represented in levels
will be set to missing. order
is a vector of integers giving a permutation of the levels default order. If preserve_order
is true
orders levels as they appear in the data.
Either input Stat.color_discrete_hue
as an argument to plot
, or set discrete_color_scale
in a Theme.
Examples
julia> x = Scale.color_discrete_hue()
Gadfly.Scale.DiscreteColorScale(Gadfly.Scale.default_discrete_colors, nothing, nothing, true)
julia> x.f(3)
3-element Array{ColorTypes.Color,1}:
LCHab{Float32}(70.0,60.0,240.0)
LCHab{Float32}(80.0,70.0,100.435)
LCHab{Float32}(65.8994,62.2146,353.998)
Gadfly.Scale.color_discrete_manual
— Methodcolor_discrete_manual(colors...; levels=nothing, order=nothing)
Similar to color_discrete_hue
except that colors for each level are specified directly instead of being computed by a function.
Gadfly.Scale.color_log
— Functioncolor_log[(; minvalue=nothing, maxvalue=nothing, colormap)]
Similar to Scale.color_continuous
, except that color
is log transformed.
Gadfly.Scale.color_log10
— Functioncolor_log10[(; minvalue=nothing, maxvalue=nothing, colormap)]
Similar to Scale.color_continuous
, except that color
is log10 transformed.
Gadfly.Scale.color_log2
— Functioncolor_log2[(; minvalue=nothing, maxvalue=nothing, colormap)]
Similar to Scale.color_continuous
, except that color
is log2 transformed.
Gadfly.Scale.color_sqrt
— Functioncolor_sqrt[(; minvalue=nothing, maxvalue=nothing, colormap)]
Similar to Scale.color_continuous
, except that color
is sqrt transformed.
Gadfly.Scale.group_discrete
— Methodgroup_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Similar to Scale.x_discrete
, except applied to the group
aesthetic.
Gadfly.Scale.lab_gradient
— Methodfunction lab_gradient(cs...)
Can be applied to other types, e.g. Scale.lab_gradient("blue","ghostwhite","red")
Gadfly.Scale.lab_gradient
— Methodfunction lab_gradient(cs::Color...)
Generate a function f(p)
that creates a gradient between n≥2 colors, where 0≤p≤1
. If you have a collection of colors, then use the splatting operator ...
:
f = Scale.lab_gradient(range(HSV(0,1,1), stop=HSV(250,1,1), length=100)...)
Function f
can be used like so: Scale.color_continuous(colormap=f)
.
Gadfly.Scale.lab_rainbow
— Methodlab_rainbow(l, c, h0, n)
Generate n
colors in the LCHab colorspace by using a fixed luminance l
and chroma c
, and varying the hue, starting at h0
.
Gadfly.Scale.lchabmix
— Methodfunction lchabmix(c0_, c1_, r, power)
Gadfly.Scale.linestyle_discrete
— Methodlinestyle_discrete(; levels=nothing, order=nothing, preserve_order=true)
A discrete scale that maps the categorical values in the linestyle
aesthetic to the values in Theme().line_style
. levels
are the categorical levels, and level order will be respected. order
is a vector of integers giving a permutation of the levels default order. If preserve_order
is true
levels are ordered as they appear in the data.
Gadfly.Scale.luv_rainbow
— Methodluv_rainbow(l, c, h0, n)
Generate n
colors in the LCHuv colorspace by using a fixed luminance l
and chroma c
, and varying the hue, starting at h0
.
Gadfly.Scale.shape_discrete
— Methodshape_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Similar to Scale.x_discrete
, except applied to the shape
aesthetic.
Gadfly.Scale.shape_identity
— Methodshape_identity()
Gadfly.Scale.size_area
— FunctionScale.size_area(f=default_continuous_sizes; minvalue=0.0, maxvalue=nothing)
Similar to Scale.size_radius
, except that the values in the size
aesthetic are scaled to area rather than radius, before mapping to x-axis units or Measure
units.
Gadfly.Scale.size_continuous
— Functionsize_continuous[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
To be updated in Gadfly 2.0. Now try out the new Scale.size_radius
and Scale.size_area
.
Gadfly.Scale.size_discrete
— Methodsize_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Similar to Scale.x_discrete
, except applied to the size
aesthetic.
Gadfly.Scale.size_discrete2
— Functionsize_discrete2(f=default_discrete_sizes;
levels=nothing, order=nothing, preserve_order=true)
A discrete size scale that maps the categorical values in the size
aesthetic to x-axis units or Measure
units (from Measures.jl). f
is a function that produces a vector of size units. levels
are the categorical levels, and level order will be respected. order
is a vector of integers giving a permutation of the levels default order. If preserve_order
is true
levels are ordered as they appear in the data.
Gadfly.Scale.size_identity
— Methodsize_identity()
Gadfly.Scale.size_radius
— FunctionScale.size_radius(f=default_continuous_sizes; minvalue=0.0, maxvalue=nothing)
A scale for continuous sizes. Values in the size
aesthetic are mapped either to:
- x-axis units (if
maxvalue=nothing
), or Measure
units (from Measures.jl).
If maxvalue
is specified, the continuous sizes are converted to a proportion (between minvalue
and maxvalue
), and then mapped to absolute sizes using the function f(p)
where 0≤p≤1
.
Gadfly.Scale.slope_continuous
— Functionslope_continuous[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Gadfly.Scale.weighted_color_mean
— Methodfunction weighted_color_mean(cs::AbstractArray{Lab{T},1},
ws::AbstractArray{S,1}) where {S <: Number,T}
Return the mean of Lab colors cs
as weighted by ws
.
Gadfly.Scale.x_asinh
— Functionx_asinh[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.x_continuous
, except that the aesthetics are asinh
transformed and the labels
function inputs transformed values.
Gadfly.Scale.x_continuous
— Functionx_continuous[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Map the x
, xmin
, xmax
, xintercept
, xviewmin
, xviewmax
and xend
aesthetics to x positions in Cartesian coordinates, which are presumed to be numerical, using an identity transform. minvalue
and maxvalue
set soft lower and upper bounds. (Use Coord.cartesian
to enforce a hard bound.) labels
is a function which maps a coordinate value to a string label. format
is one of :plain
, :scientific
, :engineering
, or :auto
. Set scalable
to false to prevent zooming on this axis. See also x_log10
, x_log2
, x_log
, x_asinh
, and x_sqrt
for alternatives to the identity transform.
Gadfly.Scale.x_discrete
— Methodx_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Map the x
, xmin
, xmax
, xintercept
, xviewmin
, xviewmax
and xend
aesthetics, which are presumed to be categorical, to Cartesian coordinates. Unlike Scale.x_continuous
, each unique x value will be mapped to equally spaced positions, regardless of value.
By default continuous scales are applied to numerical data. If data consists of numbers specifying categories, explicitly adding Scale.x_discrete
is the easiest way to get that data to plot appropriately.
labels
is either a function which maps a coordinate value to a string label, or a vector of strings of the same length as the number of unique values in the aesthetic. levels
gives values for the scale. Order will be respected and anything in the data that's not represented in levels
will be set to missing
. order
is a vector of integers giving a permutation of the levels default order.
See also group_discrete
, shape_discrete
, size_discrete
, linestyle_discrete
, and alpha_discrete
.
Gadfly.Scale.x_distribution
— Methodx_distribution()
Gadfly.Scale.x_func
— Methodx_func()
Gadfly.Scale.x_log
— Functionx_log[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.x_continuous
, except that the aesthetics are log
transformed and the labels
function inputs transformed values.
Gadfly.Scale.x_log10
— Functionx_log10[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.x_continuous
, except that the aesthetics are log10
transformed and the labels
function inputs transformed values.
Gadfly.Scale.x_log2
— Functionx_log2[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.x_continuous
, except that the aesthetics are log2
transformed and the labels
function inputs transformed values.
Gadfly.Scale.x_sqrt
— Functionx_sqrt[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.x_continuous
, except that the aesthetics are sqrt
transformed and the labels
function inputs transformed values.
Gadfly.Scale.xgroup
— Methodxgroup[(; labels=nothing, levels=nothing, order=nothing)]
A discrete scale for use with Geom.subplot_grid
.
Gadfly.Scale.y_asinh
— Functiony_asinh[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.y_continuous
, except that the aesthetics are asinh
transformed and the labels
function inputs transformed values.
Gadfly.Scale.y_continuous
— Functiony_continuous[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Map the y
, ymin
, ymax
, yintercept
, intercept
, middle
, upper_fence
, lower_fence
, upper_hinge
, lower_hinge
, yviewmin
, yviewmax
and yend
aesthetics to y positions in Cartesian coordinates, which are presumed to be numerical, using an identity transform. minvalue
and maxvalue
set soft lower and upper bounds. (Use Coord.cartesian
to enforce a hard bound.) labels
is a function which maps a coordinate value to a string label. format
is one of :plain
, :scientific
, :engineering
, or :auto
. Set scalable
to false to prevent zooming on this axis. See also y_log10
, y_log2
, y_log
, y_asinh
, and y_sqrt
for alternatives to the identity transform.
Gadfly.Scale.y_discrete
— Methody_discrete[(; labels=nothing, levels=nothing, order=nothing)]
Map the y
, ymin
, ymax
, yintercept
, intercept
, middle
, upper_fence
, lower_fence
, upper_hinge
, lower_hinge
, yviewmin
, yviewmax
and yend
aesthetics, which are presumed to be categorical, to Cartesian coordinates. Unlike Scale.x_continuous
, each unique y value will be mapped to equally spaced positions, regardless of value.
By default continuous scales are applied to numerical data. If data consists of numbers specifying categories, explicitly adding Scale.y_discrete
is the easiest way to get that data to plot appropriately.
labels
is either a function which maps a coordinate value to a string label, or a vector of strings of the same length as the number of unique values in the aesthetic. levels
gives values for the scale. Order will be respected and anything in the data that's not represented in levels
will be set to missing
. order
is a vector of integers giving a permutation of the levels default order.
See also group_discrete
, shape_discrete
, size_discrete
, linestyle_discrete
, and alpha_discrete
.
Gadfly.Scale.y_distribution
— Methody_distribution()
Gadfly.Scale.y_func
— Methody_func()
Gadfly.Scale.y_log
— Functiony_log[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.y_continuous
, except that the aesthetics are log
transformed and the labels
function inputs transformed values.
Gadfly.Scale.y_log10
— Functiony_log10[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.y_continuous
, except that the aesthetics are log10
transformed and the labels
function inputs transformed values.
Gadfly.Scale.y_log2
— Functiony_log2[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.y_continuous
, except that the aesthetics are log2
transformed and the labels
function inputs transformed values.
Gadfly.Scale.y_sqrt
— Functiony_sqrt[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
format=nothing, minticks=2, maxticks=10, scalable=true)]
Similar to Scale.y_continuous
, except that the aesthetics are sqrt
transformed and the labels
function inputs transformed values.
Gadfly.Scale.ygroup
— Methodygroup[(; labels=nothing, levels=nothing, order=nothing)]
A discrete scale for use with Geom.subplot_grid
.
Gadfly.Scale.z_func
— Methodz_func()