packages

plot::scale

On this page

Axis scales: the map from data values to a linear screen coordinate.

Enums

ScaleSource

pub enum Scale

How an axis maps values to positions.

nabi
use plot::Scale;

assert(Scale::Log(10.0).forward(1000.0) == 3.0);
assert(Scale::Symlog { base: 10.0, linthresh: 1.0 }.forward(-10.0) == -2.0);
  • Linear§

    Source

    Evenly spaced values.

  • Log(f64)§

    Source

    Logarithmic in this base; values must be positive.

  • Symlog§

    Source

    Linear within [-linthresh, linthresh], logarithmic outside, so zero and both signs fit (matplotlib's symlog).

  • Linear in seconds since 1970-01-01 UTC, with calendar ticks.

  • pub fn forward(self, v: f64) -> f64§

    Source

    The screen-linear coordinate of v.

    nabi
    assert(plot::Scale::Log(2.0).forward(8.0) == 3.0);
    
  • pub fn inverse(self, u: f64) -> f64§

    Source

    The value at screen-linear coordinate u.

    nabi
    use plot::Scale;
    
    let s = Scale::Symlog { base: 10.0, linthresh: 2.0 };
    assert((s.inverse(s.forward(-300.0)) + 300.0).abs() < 1e-9);
    
  • pub fn accepts(self, v: f64) -> bool§

    Source

    Whether v can be shown on this scale.

    nabi
    assert(!plot::Scale::Log(10.0).accepts(-1.0) && plot::Scale::Linear.accepts(-1.0));