Skip to content

Commit

Permalink
Replace step with stairs and correct subplot_adjusts
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed May 21, 2022
1 parent 7735701 commit 21e7a63
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 21 deletions.
15 changes: 7 additions & 8 deletions cheatsheets.tex
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,13 @@
\vspace{\fill}
% --- Advanced plots --------------------------------------------------------
\begin{myboxed}{Advanced plots}
\plot{advanced-step.pdf}{\textbf{step}(X,Y,[fmt],…)}
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.step.html}
{\mandatory{X},
\mandatory{Y},
\optional{fmt},
\optional{color},
\optional{marker},
\optional{where} }
\plot{advanced-stairs.pdf}{\textbf{stairs}(Y,[edges],…)}
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.stairs.html}
{\mandatory{Y},
\optional{edges},
\optional{orientation},
\optional{baseline},
\optional{fill} }
{}
\plot{advanced-boxplot.pdf}{\textbf{boxplot}(X,…)}
{https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html}
Expand Down
16 changes: 9 additions & 7 deletions scripts/adjustements.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,24 @@ def int_arrow(p0, p1):
ext_arrow( (x-4, y), (x, y), (x+5, y), (x+9, y) )
ax.text(x-4.5, y, "wspace", ha="right", va="center", size="x-small", zorder=20)

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

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

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

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

int_arrow((0, -5), (100, -5))
ax.text(50, -5, "figure width", backgroundcolor="white", zorder=30,
Expand Down
12 changes: 6 additions & 6 deletions scripts/advanced-plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Released under the BSD License
# -----------------------------------------------------------------------------

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

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

# Violin plot
Expand Down

0 comments on commit 21e7a63

Please sign in to comment.