plot#

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

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

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

Parameters:
Return type:

An array of artists that were plotted

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)
y = np.sin(x)

plt.figure();
na.plt.plot(x, y);
../_images/named_arrays.plt.plot_0_0.png

Plot an array of scalars

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

y = np.sin(x - z)

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

Plot an uncertain scalar

ux = na.NormalUncertainScalarArray(x, width=0.2)
uy = np.sin(ux)

plt.figure();
na.plt.plot(x, uy);
../_images/named_arrays.plt.plot_2_0.png

Broadcast an array of scalars against an array of matplotlib.axes.Axes

fig, ax = na.plt.subplots(axis_rows="z", nrows=z.shape["z"], sharex=True)

na.plt.plot(x, y, ax=ax, axis="x");
../_images/named_arrays.plt.plot_3_0.png

Plot a 2D Cartesian vector

v = na.Cartesian2dVectorArray(x, np.sin(x))

plt.figure()
na.plt.plot(v)
ScalarArray(
    ndarray=<matplotlib.lines.Line2D object at 0x79a6481b5ee0>,
    axes=(),
)
../_images/named_arrays.plt.plot_4_1.png