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.alpha_continuousMethod
alpha_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.

source
Gadfly.Scale.color_continuousFunction
color_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.

source
Gadfly.Scale.color_discrete_hueFunction
color_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 Colors. 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)
source
Gadfly.Scale.lab_gradientMethod
function 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).

source
Gadfly.Scale.lab_rainbowMethod
lab_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.

source
Gadfly.Scale.linestyle_discreteMethod
linestyle_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.

source
Gadfly.Scale.luv_rainbowMethod
luv_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.

source
Gadfly.Scale.size_areaFunction
Scale.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.

source
Gadfly.Scale.size_discrete2Function
size_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.

source
Gadfly.Scale.size_radiusFunction
Scale.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.

source
Gadfly.Scale.slope_continuousFunction
slope_continuous[(; minvalue=nothing, maxvalue=nothing, labels=nothing,
                 format=nothing, minticks=2, maxticks=10, scalable=true)]
source
Gadfly.Scale.weighted_color_meanMethod
function 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.

source
Gadfly.Scale.x_asinhFunction
x_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.

source
Gadfly.Scale.x_continuousFunction
x_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.

source
Gadfly.Scale.x_discreteMethod
x_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.

source
Gadfly.Scale.x_logFunction
x_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.

source
Gadfly.Scale.x_log10Function
x_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.

source
Gadfly.Scale.x_log2Function
x_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.

source
Gadfly.Scale.x_sqrtFunction
x_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.

source
Gadfly.Scale.y_asinhFunction
y_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.

source
Gadfly.Scale.y_continuousFunction
y_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.

source
Gadfly.Scale.y_discreteMethod
y_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.

source
Gadfly.Scale.y_logFunction
y_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.

source
Gadfly.Scale.y_log10Function
y_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.

source
Gadfly.Scale.y_log2Function
y_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.

source
Gadfly.Scale.y_sqrtFunction
y_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.

source