3636 %
3737 emph = { plot, scatter, imshow, bar, contourf, pie, subplots, spines,
3838 add_gridspec, add_subplot, set_xscale, set_minor_locator,
39- set_minor_formatter, tick_params, fill_betweenx, text,
39+ set_minor_formatter, tick_params, fill_betweenx, text, legend,
4040 errorbar, boxplot, hist, title, xlabel, ylabel, suptitle },
4141 emphstyle = {\ttfamily\bfseries }
4242}
@@ -78,7 +78,7 @@ \section*{\LARGE \rmfamily
7878
7979\includegraphics [width=\linewidth ]{anatomy-cropped.pdf}
8080
81- \subsection* {Figure, axes \& spines }
81+ \subsection* {\rmfamily Figure, axes \& spines }
8282
8383% -----------------------------------------------------------------------------
8484\begin {tabular }{@{}m{.821\linewidth }m{.169\linewidth }}
@@ -113,7 +113,7 @@ \subsection*{Figure, axes \& spines}
113113
114114
115115% -----------------------------------------------------------------------------
116- \subsection* {Ticks \& labels }
116+ \subsection* {\rmfamily Ticks \& labels }
117117
118118\ begin{lstlisting} [basicstyle=\ttfamily\small]
119119 from mpl.ticker import MultipleLocator as ML
@@ -125,7 +125,7 @@ \subsection*{Ticks \& labels}
125125\includegraphics [width=\linewidth ]{tick-multiple-locator.pdf}
126126
127127% -----------------------------------------------------------------------------
128- \subsection* {Lines \& markers }
128+ \subsection* {\rmfamily Lines \& markers }
129129
130130\ begin{lstlisting}
131131 X = np.linspace(0.1, 10*np.pi, 1000)
@@ -135,7 +135,7 @@ \subsection*{Lines \& markers}
135135\includegraphics [width=\linewidth ]{sine-marker.pdf}
136136
137137% -----------------------------------------------------------------------------
138- \subsection* {Scales \& Projections }
138+ \subsection* {\rmfamily Scales \& Projections }
139139
140140\ begin{lstlisting}
141141 fig, ax = plt.subplots()
@@ -144,7 +144,7 @@ \subsection*{Scales \& Projections}
144144\end {lstlisting }
145145\includegraphics [width=\linewidth ]{sine-logscale.pdf}
146146
147- \subsection* {Text \& Ornaments }
147+ \subsection* {\rmfamily Text \& Ornaments }
148148\ begin{lstlisting} []
149149 ax.fill_betweenx([-1,1],[0],[2*np.pi])
150150 ax.text(0, -1, r" Period $\Phi$")
@@ -153,12 +153,33 @@ \subsection*{Text \& Ornaments}
153153
154154
155155% -----------------------------------------------------------------------------
156- \subsection* {Size \& DPI }
156+ \subsection* {\rmfamily Legend }
157+ \ begin{lstlisting} []
158+ ax.plot(X, np.sin(X), "C0", label="Sine")
159+ ax.plot(X, np.cos(X), "C1", label="Cosine")
160+ ax.legend(bbox_to_anchor=(0,1,1,.1),ncol=2,
161+ mode="expand", loc="lower left")
162+ \end {lstlisting }
163+ \includegraphics [width=\linewidth ]{sine-legend.pdf}
164+
165+
166+ % -----------------------------------------------------------------------------
167+ \subsection* {\rmfamily Colors }
168+
169+ Any color can be used but Matplotlib offers a set of colors:\\
170+ \includegraphics [width=\linewidth ]{colors-cycle.pdf} \smallskip
171+ \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
175+
176+ % -----------------------------------------------------------------------------
177+ \subsection* {\rmfamily Size \& DPI }
157178
158179Consider a square figure to be included in a two-columns A4 paper with
1591802cm margins on each side and a column separation of 1cm. The width of
160181a figure is (21 - 2*2 - 1)/2 = 8cm. One inch being 2.54cm, figure size
161- should be 3.15$ \times $ 3.15 inches .
182+ should be 3.15$ \times $ 3.15 in .
162183\ begin{lstlisting} []
163184 fig = plt.figure(figsize=(3.15,3.15), dpi=50)
164185 plt.savefig("figure.pdf", dpi=600)
0 commit comments