Skip to content

Commit fa9de50

Browse files
committed
Added annotation
1 parent eae75bd commit fa9de50

File tree

2 files changed

+41
-41
lines changed

2 files changed

+41
-41
lines changed

handout-intermediate.tex

+15-30
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@
3535
tabsize=2,
3636
%
3737
emph = { plot, scatter, imshow, bar, contourf, pie, subplots, spines,
38-
add_gridspec, add_subplot, set_xscale, set_minor_locator,
39-
set_minor_formatter, tick_params, fill_betweenx, text, legend,
40-
errorbar, boxplot, hist, title, xlabel, ylabel, suptitle },
38+
add_gridspec, add_subplot, set_xscale, set_minor_locator,
39+
annotate, set_minor_formatter, tick_params, fill_betweenx, text, legend,
40+
errorbar, boxplot, hist, title, xlabel, ylabel, suptitle },
4141
emphstyle = {\ttfamily\bfseries}
4242
}
4343

@@ -162,16 +162,24 @@ \subsection*{\rmfamily Legend}
162162
\end{lstlisting}
163163
\includegraphics[width=\linewidth]{sine-legend.pdf}
164164

165+
% -----------------------------------------------------------------------------
166+
\subsection*{\rmfamily Annotation}
167+
\begin{lstlisting}[]
168+
ax.annotate("A", (X[250],Y[250]),(X[250],-1),
169+
ha="center", va="center",arrowprops =
170+
{"arrowstyle" : "->", "color": "C1"})
171+
\end{lstlisting}
172+
\includegraphics[width=\linewidth]{sine-annotate.pdf}
165173

166174
% -----------------------------------------------------------------------------
167175
\subsection*{\rmfamily Colors}
168176

169-
Any color can be used but Matplotlib offers a set of colors:\\
177+
Any color can be used but Matplotlib offers sets of colors:\\
170178
\includegraphics[width=\linewidth]{colors-cycle.pdf} \smallskip
171179
\includegraphics[width=\linewidth]{colors-grey.pdf}\\
172-
As well as nice colormaps (viridis an magma):\\
173-
\includegraphics[width=\linewidth]{colormap-viridis.pdf} \smallskip
174-
\includegraphics[width=\linewidth]{colormap-magma.pdf} \medskip
180+
%As well as nice colormaps (viridis an magma):\\
181+
%\includegraphics[width=\linewidth]{colormap-viridis.pdf} \smallskip
182+
%\includegraphics[width=\linewidth]{colormap-magma.pdf} \medskip
175183

176184
% -----------------------------------------------------------------------------
177185
\subsection*{\rmfamily Size \& DPI}
@@ -185,29 +193,6 @@ \subsection*{\rmfamily Size \& DPI}
185193
plt.savefig("figure.pdf", dpi=600)
186194
\end{lstlisting}
187195

188-
%% \begin{tabular}{@{}m{.821\linewidth}m{.169\linewidth}}
189-
%% \begin{lstlisting}[belowskip=-\baselineskip]
190-
%% ax = plt.subplot(projection="polar")
191-
%% ax.set_rorigin(-3)
192-
%% plt.plot(X, Y, "C1-")
193-
%% \end{lstlisting}
194-
%% & \raisebox{-0.75em}{\includegraphics[width=\linewidth]{sine-polar.pdf}}
195-
%% \end{tabular}
196-
197-
198-
%% X = np.linspace(0, 2*np.pi, 10000)
199-
%% Y = np.sin(10*X)
200-
201-
%% fig = plt.figure(figsize=(5,5))
202-
%% ax = plt.subplot(projection="polar")
203-
204-
%% ax.set_xticks(np.linspace(0, 2*np.pi, 8+1 ))
205-
%% ax.set_xticklabels([])
206-
%% ax.set_yticklabels([])
207-
%% plt.ylim(-1.5, 1.5)
208-
%% plt.plot(X, Y, "C1o-", markevery=500, mec="1.0", lw=2, ms=8.5, mew=2)
209-
%% plt.savefig("../figures/sine-polar.pdf", dpi=100)
210-
%% plt.show()
211196

212197
\vfill
213198
%

scripts/sine.py

+26-11
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,31 @@
4242
# plt.show()
4343

4444

45-
fig = plt.figure(figsize=(7,1.5))
46-
plt.plot(X, np.sin(X), "C0", lw=2, label="Sine")
47-
plt.plot(X, np.cos(X), "C1", lw=2, label="Cosine")
48-
plt.legend(bbox_to_anchor = (0.0, .9, 1.02, 0.1),
49-
frameon=False, mode="expand", ncol=2, loc="lower left")
50-
plt.title("Sine and Cosine")
51-
plt.xticks([]), plt.yticks([])
52-
plt.ylim(-1.25, 1.25)
53-
plt.tight_layout()
54-
plt.savefig("../figures/sine-legend.pdf", dpi=100)
55-
plt.show()
45+
# fig = plt.figure(figsize=(7,1.5))
46+
# plt.plot(X, np.sin(X), "C0", lw=2, label="Sine")
47+
# plt.plot(X, np.cos(X), "C1", lw=2, label="Cosine")
48+
# plt.legend(bbox_to_anchor = (0.0, .9, 1.02, 0.1),
49+
# frameon=False, mode="expand", ncol=2, loc="lower left")
50+
# plt.title("Sine and Cosine")
51+
# plt.xticks([]), plt.yticks([])
52+
# plt.ylim(-1.25, 1.25)
53+
# plt.tight_layout()
54+
# plt.savefig("../figures/sine-legend.pdf", dpi=100)
55+
# plt.show()
5656

5757

58+
fig = plt.figure(figsize=(7,1.5))
59+
X = np.linspace(0, 10*np.pi, 1000)
60+
Y = np.sin(X)
61+
plt.plot(X, Y, "C1o-", markevery=50, mec="1.0", lw=2, ms=8.5, mew=2)
62+
# plt.xticks([]), plt.yticks([])
63+
plt.ylim(-1.5, 1.5)
64+
plt.annotate(" ", (X[200],Y[200]), (X[250], -1), ha="center", va="center",
65+
arrowprops = {"arrowstyle" : "->", "color": "C1"})
66+
plt.annotate("A", (X[250],Y[250]), (X[250], -1), ha="center", va="center",
67+
arrowprops = {"arrowstyle" : "->", "color": "C1"})
68+
plt.annotate(" ", (X[300],Y[300]), (X[250], -1), ha="center", va="center",
69+
arrowprops = {"arrowstyle" : "->", "color": "C1"})
70+
plt.tight_layout()
71+
plt.savefig("../figures/sine-annotate.pdf", dpi=100)
72+
# plt.show()

0 commit comments

Comments
 (0)