mplutils.convert_to_steps#
- mplutils.convert_to_steps(x, y, start_at=0.0, xlim_lower=None, xlim_upper=None)[source]#
Convert (x,y) data to steps.
- Parameters:
- xarray_like
x data, corresponding to the centers of the resulting steps.
- yarray_like
corresponding y data.
- start_at
floator “auto”, default 0.0 Start/end steps at this value.
If “auto”, start (end) at first (last) y value.
- xlim_lower, ylim_uppper
float, optional Lower/upper limits of the range.
At least one limit must be provided if x data doesn’t have constant spacing. If both lower and upper limits are provided, the lower one will be prioritized.
- Returns:
- x, y
ndarray Data corresponding to steps.
- x, y
Examples
import matplotlib.pyplot as plt import numpy as np import mplutils as mplu x = np.linspace(1.0, 10.0, 9) y = 2.0 * x _, axs = plt.subplots(1, 3, layout=mplu.FixedLayoutEngine()) axs[0].plot(x, y, "-") axs[1].plot(*mplu.convert_to_steps(x, y), "-") axs[2].plot(*mplu.convert_to_steps(x, y, start_at="auto"), "-") for ax in axs: mplu.set_axes_size(2.5, aspect=3.0 / 4.0, ax=ax)
(
Source code,png,hires.png,pdf)