Skip to content

Commit 8b63fb3

Browse files
committed
Replace step with stairs and correct subplot_adjusts
1 parent 56c1693 commit 8b63fb3

File tree

3 files changed

+22
-21
lines changed

3 files changed

+22
-21
lines changed

cheatsheets.tex

+7-8
Original file line numberDiff line numberDiff line change
@@ -432,14 +432,13 @@
432432
\vspace{\fill}
433433
% --- Advanced plots --------------------------------------------------------
434434
\begin{myboxed}{Advanced plots}
435-
\plot{advanced-step.pdf}{\textbf{step}(X,Y,[fmt],…)}
436-
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.step.html}
437-
{\mandatory{X},
438-
\mandatory{Y},
439-
\optional{fmt},
440-
\optional{color},
441-
\optional{marker},
442-
\optional{where} }
435+
\plot{advanced-stairs.pdf}{\textbf{stairs}(Y,[edges],…)}
436+
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.stairs.html}
437+
{\mandatory{Y},
438+
\optional{edges},
439+
\optional{orientation},
440+
\optional{baseline},
441+
\optional{fill} }
443442
{}
444443
\plot{advanced-boxplot.pdf}{\textbf{boxplot}(X,…)}
445444
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html}

scripts/adjustements.py

+9-7
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,24 @@ def int_arrow(p0, p1):
9191
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
9292
ax.text(x-4.5, y, "wspace", ha="right", va="center", size="x-small", zorder=20)
9393

94-
x += 45
95-
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
96-
ax.text(x-4.5, y, "right", ha="right", va="center", size="x-small", zorder=20)
94+
y=20
95+
int_arrow( (0, y), (95, y))
96+
ax.text(80, y, "right", backgroundcolor="white", ha="right", va="center",
97+
size="x-small", zorder=30)
9798

9899
y = 0
99-
x = 25
100+
x = 22.5
100101
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
101102
ax.text(x, y+9.5, "bottom", ha="center", va="bottom", size="x-small", zorder=20)
102103

103104
y += 35
104105
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
105106
ax.text(x, y-4.5, "hspace", ha="center", va="top", size="x-small", zorder=20)
106107

107-
y += 35
108-
ext_arrow( (x, y-4), (x, y), (x, y+5), (x, y+9) )
109-
ax.text(x, y-4.5, "top", ha="center", va="top", size="x-small", zorder=20)
108+
x = 31
109+
int_arrow( (x, 0), (x, 70))
110+
ax.text(x, 55, "top", backgroundcolor="white", rotation="vertical",
111+
ha="center", va="center", size="x-small", zorder=30)
110112

111113
int_arrow((0, -5), (100, -5))
112114
ax.text(50, -5, "figure width", backgroundcolor="white", zorder=30,

scripts/advanced-plots.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Released under the BSD License
44
# -----------------------------------------------------------------------------
55

6-
# Scripts to generate all the basic plots
6+
# Scripts to generate all the advanced plots
77
import numpy as np
88
import matplotlib as mpl
99
import matplotlib.pyplot as plt
@@ -15,15 +15,15 @@
1515
d = 0.01
1616
ax = fig.add_axes([d, d, 1-2*d, 1-2*d])
1717

18-
# Step plot
18+
# Stairs plot
1919
# -----------------------------------------------------------------------------
2020
X = np.linspace(0, 10, 16)
21-
Y = 4 + 2*np.sin(2*X)
22-
ax.step(X, Y, color="C1", linewidth=0.75)
21+
Y = 2*np.sin(2*X+0.3)
22+
ax.stairs(Y, color="C1", linewidth=0.75)
2323
ax.set_xlim(0, 8), ax.set_xticks(np.arange(1, 8))
24-
ax.set_ylim(0, 8), ax.set_yticks(np.arange(1, 8))
24+
ax.set_ylim(-4, 4), ax.set_yticks(np.arange(-4, 4))
2525
ax.grid(linewidth=0.125)
26-
plt.savefig("../figures/advanced-step.pdf")
26+
plt.savefig("../figures/advanced-stairs.pdf")
2727
ax.clear()
2828

2929
# Violin plot

0 commit comments

Comments
 (0)