toyplot.projection module

class toyplot.projection.Piecewise(segments)[source]

Bases: toyplot.projection.Projection

Compute a projection from an arbitrary collection of linear and log segments.

class Segment(scale, domain_bounds_min, domain_min, domain_max, domain_bounds_max, range_bounds_min, range_min, range_max, range_bounds_max)[source]

Bases: object

class Container[source]

Bases: object

Piecewise.inverse(range_values)[source]

Transform values from the range to the domain.

class toyplot.projection.Projection[source]

Bases: object

Base class for objects that can map from domain to range and range to domain.

inverse(range_values)[source]
toyplot.projection.linear(domain_min, domain_max, range_min, range_max)[source]

Return an instance of toyplot.projection.Piecewise that performs a linear projection.

Parameters:
  • domain_min, domain_max (number) – Defines a closed interval of domain values that will be mapped to the range.
  • range_min, range_max (number) – Defines a closed interval of range values that will be mapped to the domain.
Returns:

projection

Return type:

toyplot.projection.Piecewise

toyplot.projection.log(base, domain_min, domain_max, range_min, range_max, linear_domain_min=-1, linear_domain_max=1)[source]

Return an instance of toyplot.projection.Piecewise that performs a log projection.

The returned projection will work correctly with both positive, negative, and zero domain values. To support mapping zero, the projection will switch from log projection to a linear projection within a user-defined region around the origin.

Parameters:
  • base (number) – Logarithmic base used to map from domain values to range values.
  • domain_min, domain_max (number) – Defines a closed interval of domain values that will be mapped to the range.
  • range_min, range_max (number) – Defines a closed interval of range values that will be mapped to the domain.
  • linear_domain_min, linear_domain_max (number, optional) – Defines an interval of domain values around the origin that will be mapped linearly.
Returns:

projection

Return type:

toyplot.projection.Piecewise

toyplot.projection.mix(a, b, amount)[source]