Scales

Scales are functions that map from an input domain to an output range. Quantitative scales have a continuous domain, such as the set of real numbers, or dates. There are also ordinal scales, which have a discrete domain, such as a set of names or categories.

Quantitative scale

class glumpy.transforms.QuantitativeScale(code, *args, **kwargs)

Bases: glumpy.transforms.transform.Transform

Abstract quantitative scale.

The transform is connected to the following events:

  • on_attach: Transform initialization
clamp

Whether to clamp value when out of range

discard

Whether to discard value when out of range

domain

Input domain

process_kwargs(**kwargs)

Process kwargs as given in __init__() or __call__()

range

Output range

Linear scale

class glumpy.transforms.LinearScale(*args, **kwargs)

Bases: glumpy.transforms.quantitative_scale.QuantitativeScale

Linear scales are the most common scale, and a good default choice to map a continuous input domain to a continuous output range. The mapping is linear in that the output range value y can be expressed as a linear function of the input domain value x: y = mx + b. The input domain is typically a dimension of the data that you want to visualize, such as the height of students (measured in meters) in a sample population. The output range is typically a dimension of the desired output visualization, such as the height of bars (measured in pixels) in a histogram.

Parameters:
  • domain (2-tuple) – Input domains. Default is (-1,+1).
  • range (2-tuple) – Output range. Default is (-1,+1).
  • clamp (bool) – Clamping test. Default is False.
  • discard (bool) – Discard test. Default is True.

Power scale

class glumpy.transforms.PowerScale(*args, **kwargs)

Bases: glumpy.transforms.quantitative_scale.QuantitativeScale

Power scales are similar to linear scales, except there’s an exponential transform that is applied to the input domain value before the output range value is computed. The mapping to the output range value y can be expressed as a function of the input domain value x: y = mx^k + b, where k is the exponent value. Power scales also support negative values, in which case the input value is multiplied by -1, and the resulting output value is also multiplied by -1.

Parameters:
  • domain (2-tuple) – Input domains. Default is (-1,+1).
  • range (2-tuple) – Output range. Default is (-1,+1).
  • exponent (float) – Power exponent. Default is 1.
  • clamp (bool) – Clamping test. Default is False.
  • discard (bool) – Discard test. Default is True.
exponent

Input exponent for xyz

Log scale

class glumpy.transforms.LogScale(*args, **kwargs)

Bases: glumpy.transforms.quantitative_scale.QuantitativeScale

Log scales are similar to linear scales, except there’s a logarithmic transform that is applied to the input domain value before the output range value is computed. The mapping to the output range value y can be expressed as a function of the input domain value x: y = m log(x) + b.

As log(0) is negative infinity, a log scale must have either an exclusively-positive or exclusively-negative domain; the domain must not include or cross zero. A log scale with a positive domain has a well-defined behavior for positive values, and a log scale with a negative domain has a well-defined behavior for negative values (the input value is multiplied by -1, and the resulting output value is also multiplied by -1). The behavior of the scale is undefined if you pass a negative value to a log scale with a positive domain or vice versa.

Parameters:
  • domain (2-tuple) – Input domains. Default is (-1,+1).
  • range (2-tuple) – Output range. Default is (-1,+1).
  • base (float) – Log base. Default is 10.
  • clamp (bool) – Clamping test. Default is False.
  • discard (bool) – Discard test. Default is True.
base

Input base