From 6675c3ddaa5ff481f77a5faa5187cded3ad9a0ec Mon Sep 17 00:00:00 2001 From: mariamalykh Date: Fri, 19 May 2023 12:19:47 +0000 Subject: [PATCH 1/2] added Stairs to basic plot types --- galleries/plot_types/basic/stairs.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 galleries/plot_types/basic/stairs.py diff --git a/galleries/plot_types/basic/stairs.py b/galleries/plot_types/basic/stairs.py new file mode 100644 index 000000000000..815ec302268f --- /dev/null +++ b/galleries/plot_types/basic/stairs.py @@ -0,0 +1,27 @@ +""" +============== +stairs(x, y) +============== + +See `~matplotlib.axes.Axes.stairs`. +""" +import matplotlib.pyplot as plt +import numpy as np + +plt.style.use('_mpl-gallery') + +# make data +x = np.arange(14) +centers = x[:-1] + np.diff(x) / 2 +y = -(centers - 4) ** 2 + 8 + +# plot +fig, ax = plt.subplots() + +ax.stairs(y - 1, x, baseline=None, label='stairs()') +plt.plot(centers, y - 1, 'o--', color='grey', alpha=0.3) + +ax.set(xlim=(0, 8), xticks=np.arange(1, 8), + ylim=(0, 8), yticks=np.arange(1, 8)) + +plt.show() From b2634a608a945271382330752cc4ea260a68e99b Mon Sep 17 00:00:00 2001 From: mariamalykh Date: Fri, 19 May 2023 16:16:23 +0000 Subject: [PATCH 2/2] replaced step with stairs in basic plot types --- galleries/plot_types/basic/step.py | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100644 galleries/plot_types/basic/step.py diff --git a/galleries/plot_types/basic/step.py b/galleries/plot_types/basic/step.py deleted file mode 100644 index 558550a5c498..000000000000 --- a/galleries/plot_types/basic/step.py +++ /dev/null @@ -1,26 +0,0 @@ -""" -========== -step(x, y) -========== - -See `~matplotlib.axes.Axes.step`. -""" -import matplotlib.pyplot as plt -import numpy as np - -plt.style.use('_mpl-gallery') - -# make data -np.random.seed(3) -x = 0.5 + np.arange(8) -y = np.random.uniform(2, 7, len(x)) - -# plot -fig, ax = plt.subplots() - -ax.step(x, y, linewidth=2.5) - -ax.set(xlim=(0, 8), xticks=np.arange(1, 8), - ylim=(0, 8), yticks=np.arange(1, 8)) - -plt.show()