stairs#

named_arrays.plt.stairs(*args, ax=None, axis=None, where=True, **kwargs)#

A thin wrapper around matplotlib.axes.Axes.stairs() for named arrays.

The main difference of this function from matplotlib.pyplot.stairs() is the addition of the axis parameter indicating along which axis the lines should be connected.

Another difference is that this function swaps the order of values and edges so that the signature matches plot().

Parameters:
Return type:

ScalarArray[ndarray[tuple[Any, …], dtype[None | Artist]]]

Examples

Plot a single scalar

import numpy as np
import matplotlib.pyplot as plt
import named_arrays as na

x = na.linspace(0, 2 * np.pi, axis="x",  num=101)

a = na.linspace(0, 2 * np.pi, axis="x", num=100, centers=True)
y = np.sin(a)

plt.figure();
na.plt.stairs(x, y);
../_images/named_arrays.plt.stairs_0_0.png

Plot an array of scalars

z = na.linspace(0, np.pi, axis="z", num=5)

y = np.sin(a - z)

plt.figure();
na.plt.stairs(x, y, axis="x");
../_images/named_arrays.plt.stairs_1_0.png

Plot an uncertain scalar

ua = na.NormalUncertainScalarArray(a, width=0.2)
uy = np.sin(ua)

plt.figure();
na.plt.stairs(x, uy);
../_images/named_arrays.plt.stairs_2_0.png