8000 Fix typos in sine plots · matplotlib/cheatsheets@d5bdedd · GitHub
[go: up one dir, main page]

Skip to content

Commit d5bdedd

Browse files
committed
Fix typos in sine plots
- Use `C1` instead of `orange` to match other plots. - Remove extra plot in `sine-logscale.pdf`, which causes a bit of artifacting around the line. - Ensure text matches what is actually plotted for `markevery` settings; note I divided by 10 so that the text would fit in the block. Fixes #133
1 parent 982b063 commit d5bdedd

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

handout-beginner.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ \section*{\LARGE \rmfamily
8383
%
8484
\fbox{2} \textbf{Prepare}
8585
\begin{lstlisting}
86-
X = np.linspace(0, 4*np.pi, 1000)
86+
X = np.linspace(0, 10*np.pi, 1000)
8787
Y = np.sin(X)
8888
\end{lstlisting}
8989
%

handout-intermediate.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ \subsection*{\rmfamily Lines \& markers}
130130
\begin{lstlisting}
131131
X = np.linspace(0.1, 10*np.pi, 1000)
132132
Y = np.sin(X)
133-
ax.plot(X, Y, "C1o:", markevery=25, mec="1.0")
133+
ax.plot(X, Y, "C1o:", markevery=50, mec="1.0")
134134
\end{lstlisting}
135135
\includegraphics[width=\linewidth]{sine-marker.pdf}
136136

@@ -140,7 +140,7 @@ \subsection*{\rmfamily Scales \& projections}
140140
\begin{lstlisting}
141141
fig, ax = plt.subplots()
142142
ax.set_xscale("log")
143-
ax.plot(X, Y, "C1o-", markevery=25, mec="1.0")
143+
ax.plot(X, Y, "C1o-", markevery=50, mec="1.0")
144144
\end{lstlisting}
145145
\includegraphics[width=\linewidth]{sine-logscale.pdf}
146146

scripts/sine.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,36 +16,42 @@
1616
ROOT_DIR / 'styles/sine-plot.mplstyle',
1717
])
1818

19-
X = np.linspace(0.1, 10*np.pi, 10000)
19+
X = np.linspace(0, 10*np.pi, 1000)
2020
Y = np.sin(X)
2121

22-
(fig, ax) = plt.subplots(figsize=(5.7/2.54, 1.2/2.54))
22+
23+
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.2/2.54))
2324
ax.set_yticks(np.linspace(-1, 1, 5))
24-
ax.plot(X, Y, color="orange")
25+
ax.plot(X, Y, color="C1")
2526
fig.savefig(ROOT_DIR / "figures/sine.pdf")
2627

27-
(fig, ax) = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
28-
ax.plot(X, Y, "C1o:", markevery=500, mec="1.0")
28+
29+
X = np.linspace(0.1, 10*np.pi, 1000)
30+
Y = np.sin(X)
31+
32+
33+
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
34+
ax.plot(X, Y, "C1o:", markevery=50, mec="1.0")
2935
ax.set_ylim(-1.5, 1.5)
3036
fig.savefig(ROOT_DIR / "figures/sine-marker.pdf")
3137

38+
3239
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
3340
ax.set_xscale("log")
34-
ax.plot(X, Y, "-")
35-
ax.plot(X, Y, "C1o-", markevery=500, mec="1.0")
41+
ax.plot(X, Y, "C1o-", markevery=50, mec="1.0")
3642
ax.set_ylim(-1.5, 1.5)
3743
fig.savefig(ROOT_DIR / "figures/sine-logscale.pdf")
3844

3945

40-
(fig, ax) = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
46+
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
4147
ax.plot(X, Y, "C1")
4248
ax.fill_betweenx([-1.5, 1.5], [0], [2*np.pi], color=".9")
4349
ax.text(0, -1, r" Period $\Phi$", va="top")
4450
ax.set_ylim(-1.5, 1.5)
4551
fig.savefig(ROOT_DIR / "figures/sine-period.pdf")
4652

4753

48-
(fig, ax) = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
54+
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
4955
ax.plot(X, np.sin(X), "C0", label="Sine")
5056
ax.plot(X, np.cos(X), "C1", label="Cosine")
5157
ax.legend(bbox_to_anchor=(0.0, .9, 1.02, 0.1),
@@ -56,7 +62,7 @@
5662
fig.savefig(ROOT_DIR / "figures/sine-legend.pdf")
5763

5864

59-
(fig, ax) = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
65+
fig, ax = plt.subplots(figsize=(5.7/2.54, 1.0/2.54))
6066
X = np.linspace(0, 10*np.pi, 1000)
6167
Y = np.sin(X)
6268
ax.plot(X, Y, "C1o-", markevery=50, mec="1.0")

0 commit comments

Comments
 (0)
0