Skip to content

Commit aab94f3

Browse files
committed
Switch to OO interface only + style tweak
1 parent d062ab5 commit aab94f3

File tree

7 files changed

+35
-28
lines changed

7 files changed

+35
-28
lines changed

cheatsheets-1.png

4.76 KB
Loading

cheatsheets-2.png

3.96 KB
Loading

cheatsheets.pdf

7.22 KB
Binary file not shown.

cheatsheets.tex

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@
7070
UprightFont = Regular,
7171
ItalicFont = Italic,
7272
BoldFont = Bold ]
73+
\newfontfamily\RobotoSlab{Robot Slab} [
74+
Path = fonts/roboto-slab/RobotoSlab-,
75+
Extension = .ttf,
76+
UprightFont = Light,
77+
BoldFont = Regular ]
7378
\newfontfamily\Roboto{Roboto}[
7479
Path = fonts/roboto/Roboto-, Extension = .ttf,
7580
UprightFont = Regular,
@@ -224,17 +229,18 @@
224229
rightline=true,
225230
leftline=true,
226231
bottomline=true,
227-
linecolor=black!10,
232+
linecolor=black!0,
228233
frametitleaboveskip=0.5em,
229234
frametitlebelowskip=0.5em,
230235
innerbottommargin=.5\baselineskip,
231236
innerrightmargin=.5em,
232237
innerleftmargin=.5em,
233238
%userdefinedwidth=1\textwidth,
234-
frametitle={\scshape \bfseries \sffamily #1},
239+
% frametitle={\scshape \bfseries \sffamily #1},
240+
frametitle={\footnotesize \RobotoSlab \bfseries \hspace*{0mm} #1},
235241
% frametitlerule=true,
236242
%frametitlerulecolor=red,
237-
frametitlebackgroundcolor=black!10,
243+
frametitlebackgroundcolor=black!5,
238244
frametitlerulewidth=2pt]}
239245
{\end{mdframed}}
240246

handout-beginner.pdf

761 Bytes
Binary file not shown.

handout-beginner.png

8.34 KB
Loading

handout-beginner.tex

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@
3434
showtabs=false,
3535
tabsize=2,
3636
%
37-
emph = { plot, scatter, imshow, bar, contourf, pie, subplots,
38-
errorbar, boxplot, hist, title, xlabel, ylabel, suptitle },
37+
emph = { plot, scatter, imshow, bar, contourf, pie, subplots, show, savefig,
38+
errorbar, boxplot, hist, set_title, set_xlabel, set_ylabel, suptitle, },
3939
emphstyle = {\ttfamily\bfseries}
4040
}
4141

@@ -89,8 +89,9 @@ \section*{\LARGE \rmfamily
8989
%
9090
\fbox{3} \textbf{Render}
9191
\begin{lstlisting}
92-
plt.plot(X, Y)
93-
plt.show()
92+
fig, ax = plt.subplots()
93+
ax.plot(X, Y)
94+
fig.show()
9495
\end{lstlisting}
9596
%
9697
\fbox{4} \textbf{Observe} \medskip\\
@@ -106,7 +107,7 @@ \subsection*{\rmfamily Choose}
106107
\begin{lstlisting}[belowskip=-\baselineskip]
107108
X = np.random.uniform(0, 1, 100)
108109
Y = np.random.uniform(0, 1, 100)
109-
plt.scatter(X, Y)
110+
ax.scatter(X, Y)
110111
\end{lstlisting}
111112
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{basic-scatter.pdf}}
112113
\end{tabular}
@@ -115,7 +116,7 @@ \subsection*{\rmfamily Choose}
115116
\begin{lstlisting}[belowskip=-\baselineskip]
116117
X = np.arange(10)
117118
Y = np.random.uniform(1, 10, 10)
118-
plt.bar(X, Y)
119+
ax.bar(X, Y)
119120
\end{lstlisting}
120121
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{basic-bar.pdf}}
121122
\end{tabular}
@@ -124,7 +125,7 @@ \subsection*{\rmfamily Choose}
124125
\begin{lstlisting}[belowskip=-\baselineskip]
125126
Z = np.random.uniform(0, 1, (8,8)
126127

127-
plt.imshow(Z)
128+
ax.imshow(Z)
128129
\end{lstlisting}
129130
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{basic-imshow.pdf}}
130131
\end{tabular}
@@ -133,7 +134,7 @@ \subsection*{\rmfamily Choose}
133134
\begin{lstlisting}[belowskip=-\baselineskip]
134135
Z = np.random.uniform(0, 1, (8,8)
135136

136-
plt.contourf(Z)
137+
ax.contourf(Z)
137138
\end{lstlisting}
138139
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{basic-contour.pdf}}
139140
\end{tabular}
@@ -142,7 +143,7 @@ \subsection*{\rmfamily Choose}
142143
\begin{lstlisting}[belowskip=-\baselineskip]
143144
Z = np.random.uniform(0, 1, 4)
144145

145-
plt.pie(Z)
146+
ax.pie(Z)
146147
\end{lstlisting}
147148
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{basic-pie.pdf}}
148149
\end{tabular}
@@ -151,7 +152,7 @@ \subsection*{\rmfamily Choose}
151152
\begin{lstlisting}[belowskip=-\baselineskip]
152153
Z = np.random.normal(0, 1, 100)
153154

154-
plt.hist(Z)
155+
ax.hist(Z)
155156
\end{lstlisting}
156157
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{advanced-hist.pdf}}
157158
\end{tabular}
@@ -160,7 +161,7 @@ \subsection*{\rmfamily Choose}
160161
\begin{lstlisting}[belowskip=-\baselineskip]
161162
X = np.arange(5)
162163
Y = np.random.uniform(0,1,5)
163-
plt.errorbar(X, Y, Y/4)
164+
ax.errorbar(X, Y, Y/4)
164165
\end{lstlisting}
165166
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{advanced-errorbar.pdf}}
166167
\end{tabular}
@@ -169,7 +170,7 @@ \subsection*{\rmfamily Choose}
169170
\begin{lstlisting}[belowskip=-\baselineskip]
170171
Z = np.random.normal(0,1,(100,3))
171172

172-
plt.boxplot(Z)
173+
ax.boxplot(Z)
173174
\end{lstlisting}
174175
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{advanced-boxplot.pdf}}
175176
\end{tabular}
@@ -187,7 +188,7 @@ \subsection*{\rmfamily Tweak}
187188
\begin{lstlisting}[belowskip=-\baselineskip]
188189
X = np.linspace(0,10,100)
189190
Y = np.sin(X)
190-
plt.plot(X, Y, color="black")
191+
ax.plot(X, Y, color="black")
191192
\end{lstlisting}
192193
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-color.pdf}}
193194
\end{tabular}
@@ -196,7 +197,7 @@ \subsection*{\rmfamily Tweak}
196197
\begin{lstlisting}[belowskip=-\baselineskip]
197198
X = np.linspace(0,10,100)
198199
Y = np.sin(X)
199-
plt.plot(X, Y, linestyle="--")
200+
ax.plot(X, Y, linestyle="--")
200201
\end{lstlisting}
201202
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-linestyle.pdf}}
202203
\end{tabular}
@@ -205,7 +206,7 @@ \subsection*{\rmfamily Tweak}
205206
\begin{lstlisting}[belowskip=-\baselineskip]
206207
X = np.linspace(0,10,100)
207208
Y = np.sin(X)
208-
plt.plot(X, Y, linewidth=5)
209+
ax.plot(X, Y, linewidth=5)
209210
\end{lstlisting}
210211
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-linewidth.pdf}}
211212
\end{tabular}
@@ -214,7 +215,7 @@ \subsection*{\rmfamily Tweak}
214215
\begin{lstlisting}[belowskip=-\baselineskip]
215216
X = np.linspace(0,10,100)
216217
Y = np.sin(X)
217-
plt.plot(X, Y, marker="o")
218+
ax.plot(X, Y, marker="o")
218219
\end{lstlisting}
219220
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-marker.pdf}}
220221
\end{tabular}
@@ -232,7 +233,7 @@ \subsection*{\rmfamily Organize}
232233
\begin{lstlisting}[belowskip=-\baselineskip]
233234
X = np.linspace(0,10,100)
234235
Y1, Y1 = np.sin(X), np.cos(X)
235-
plt.plot(X, Y1, Y2)
236+
ax.plot(X, Y1, Y2)
236237
\end{lstlisting}
237238
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-multi.pdf}}
238239
\end{tabular}
@@ -261,18 +262,18 @@ \subsection*{\rmfamily Label \mdseries (everything)}
261262
% -----------------------------------------------------------------------------
262263
\begin{tabular}{@{}m{.821\linewidth}m{.169\linewidth}}
263264
\begin{lstlisting}[belowskip=-\baselineskip]
264-
plt.plot(X, Y)
265-
plt.suptitle(None)
266-
plt.title("A Sine wave")
265+
ax.plot(X, Y)
266+
fig.suptitle(None)
267+
ax.set_title("A Sine wave")
267268
\end{lstlisting}
268269
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-title.pdf}}
269270
\end{tabular}
270271
% -----------------------------------------------------------------------------
271272
\begin{tabular}{@{}m{.821\linewidth}m{.169\linewidth}}
272273
\begin{lstlisting}[belowskip=-\baselineskip]
273-
plt.plot(X, Y)
274-
plt.ylabel(None)
275-
plt.xlabel("Time")
274+
ax.plot(X, Y)
275+
ax.set_ylabel(None)
276+
ax.set_xlabel("Time")
276277
\end{lstlisting}
277278
& \raisebox{-0.75em}{\includegraphics[width=\linewidth]{plot-xlabel.pdf}}
278279
\end{tabular}
@@ -289,8 +290,8 @@ \subsection*{\rmfamily Explore}
289290
\subsection*{\rmfamily Save \mdseries (bitmap or vector format)}
290291
% -----------------------------------------------------------------------------
291292
\begin{lstlisting}[belowskip=-\baselineskip]
292-
plt.savefif("my-first-figure.png", dpi=300)
293-
plt.savefig("my-first-figure.pdf")
293+
fig.savefig("my-first-figure.png", dpi=300)
294+
fig.savefig("my-first-figure.pdf")
294295
\end{lstlisting}
295296
%
296297
\vfill

0 commit comments

Comments
 (0)