Skip to content

Commit f5fcd38

Browse files
authored
Merge pull request #9 from matplotlib/nicolas
Nicolas
2 parents 6e1ac2c + 5fc487e commit f5fcd38

22 files changed

+117
-33
lines changed

cheatsheets-1.png

2.98 KB
Loading

cheatsheets-2.png

52.3 KB
Loading

cheatsheets.tex

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
% --- Graphics ----------------------------------------------------------------
1717
\usepackage{tikz}
1818
\usepackage{graphicx}
19-
\graphicspath{{./figures/}}
19+
\graphicspath{{./figures/}{./icons/}{./logos/}}
2020
\usepackage[export]{adjustbox}
2121

2222
% --- Framed boxes ------------------------------------------------------------
@@ -250,7 +250,7 @@
250250

251251
\begin{multicols*}{5}
252252

253-
\includegraphics[width=\columnwidth]{logo.pdf}
253+
\includegraphics[width=\columnwidth]{matplotlib.pdf}
254254
%\textbf{\Large \RobotoCon Matplotlib 3.2 cheat sheet}\\
255255
%{\ttfamily https://matplotlib.org} \hfill CC-BY 4.0
256256
% \bigskip
@@ -304,6 +304,12 @@
304304

305305
% --- Getting help ----------------------------------------------------------
306306
\begin{myboxed}{Getting help}
307+
\includegraphics[height=.75em]{www.png}
308+
\href{https://matplotlib.org}
309+
{matplotlib.org}\\
310+
\includegraphics[height=.75em]{github.png}
311+
\href{https://github.com/matplotlib/matplotlib/issues}
312+
{github.com/matplotlib/matplotlib/issues}\\
307313
\includegraphics[height=.75em]{discourse.pdf}
308314
\href{https://discourse.matplotlib.org}
309315
{discourse.matplotlib.org}\\
@@ -776,7 +782,7 @@
776782
%
777783
\vspace{\fill}
778784
%
779-
\begin{myboxed}{Text aligmnents \hfill
785+
\begin{myboxed}{Text alignments \hfill
780786
\API{https://matplotlib.org/tutorials/text/text_props.html} }
781787
plt.\textbf{text}( …, ha=… , va=…, … )\\
782788

@@ -886,15 +892,18 @@
886892

887893

888894

889-
\begin{myboxed}{Color names}
895+
\begin{myboxed}{Color names \hfill
896+
\API{https://matplotlib.org/api/colors_api.html} }
890897
\includegraphics[width=\columnwidth]{colornames.pdf}
891898
\end{myboxed}
892899
%
893900
\vspace{\fill}
894901
%
895-
\begin{myboxed}{Image interpolation}
896-
plt.\textbf{imshow}(…, interpolation=…)\\
897-
plt.\textbf{contour[f]}(…, interpolation=…)\\
902+
\begin{myboxed}{Image interpolation
903+
\hfill \API{https://matplotlib.org/gallery/images_contours_and_fields/interpolation_methods.html} }
904+
\smallskip
905+
%% plt.\textbf{imshow}(…, interpolation=…)\\
906+
%% plt.\textbf{contour[f]}(…, interpolation=…)\\
898907
\includegraphics[width=\columnwidth]{interpolations.pdf}
899908
\end{myboxed}
900909

@@ -941,6 +950,8 @@
941950
\hspace*{2.5mm}~$\rightarrow$ ax.set\_xticks([])\\
942951
\textbf{… remove tick labels ?}\\
943952
\hspace*{2.5mm}~$\rightarrow$ ax.set\_[xy]ticklabels([])\\
953+
\textbf{… rotate tick labels ?}\\
954+
\hspace*{2.5mm}~$\rightarrow$ plt.[xy]ticks(rotation=90)\\
944955
\textbf{… hide top spine?}\\
945956
\hspace*{2.5mm}~$\rightarrow$ ax.spines['top'].set\_visible(False)\\
946957
\textbf{… hide legend border?}\\
@@ -958,40 +969,46 @@
958969
\textbf{… get a reversed colormap?}\\
959970
\hspace*{2.5mm}~$\rightarrow$ plt.get\_cmap(``viridis\_r'')\\
960971
\textbf{… get a discrete colormap?}\\
961-
\hspace*{2.5mm}~$\rightarrow$ plt.get\_cmap(``viridis'', 10)
962-
%% \textbf{… show a figure for one second?}\\
963-
%% \hspace*{2.5mm}~$\rightarrow$ plt.show(block=False), time.sleep(1)
972+
\hspace*{2.5mm}~$\rightarrow$ plt.get\_cmap(``viridis'', 10)\\
973+
\textbf{… show a figure for one second?}\\
974+
\hspace*{2.5mm}~$\rightarrow$ plt.show(block=False), time.sleep(1)
964975
\end{myboxed}
965976
%
966977
\vspace{\fill}
967978
%
968979
\begin{myboxed}{Performance tips}
980+
\smallskip
969981
{\ttfamily \fontsize{6pt}{7pt}\selectfont
970-
\textcolor{red}{ax.scatter(X, Y) \hfill slow}\\
971-
ax.plot(X, Y, marker="o", ls="") \hfill fast\\
982+
\textcolor{red}{scatter(X, Y) \hfill slow}\\
983+
plot(X, Y, marker="o", ls="") \hfill fast\\
972984
\hrule \smallskip
973-
\textcolor{red}{for i in range(0,n,2): \hfill (very) slow}\\
974-
\hspace*{2.5mm}~\textcolor{red}{plt.plot(X[i:i+2], Y[i:i+2])}\\
975-
976-
X0, Y0 = X[0::2], Y[0::2] \hfill fast\\
977-
X1, Y1 = X[1::2], Y[1::2]\\
978-
S = [None]*len(X)\\
979-
X = [v for t in zip(X0,X1,S) for v in t]\\
980-
Y = [v for t in zip(Y0,Y1,S) for v in t]\\
981-
plt.plot(X,Y)}
985+
\textcolor{red}{for i in range(n): plot(X[i]) \hfill slow}\\
986+
plot(sum([x+[None] for x in X],[])) \hfill fast\\
987+
\hrule \smallskip
988+
\textcolor{red}{cla(), imshow(…), canvas.draw() \hfill slow}\\
989+
im.set\_data(…), canvas.draw() \hfill fast\smallskip
990+
}
982991
\end{myboxed}
983992
%
984993
\vspace{\fill}
985994
%
986995
\begin{myboxed}{Beyond Matplotlib}
996+
\smallskip
987997
\href{https://seaborn.pydata.org/}{\textbf{Seaborn}}: Statistical Data Visualization\\
988998
\href{https://scitools.org.uk/cartopy/docs/latest/}{\textbf{Cartopy}}: Geospatial Data Processing\\
989999
\href{https://yt-project.org/doc/index.html}{\textbf{yt}}: Volumetric data Visualization\\
9901000
\href{https://mpld3.github.io}{\textbf{mpld3}}: Bringing Matplotlib to the browser\\
9911001
\href{https://datashader.org/}{\textbf{Datashader}}: Large data processing pipeline\\
9921002
\href{https://plotnine.readthedocs.io/en/latest/}{\textbf{plotnine}}: A Grammar of Graphics for Python
9931003
\end{myboxed}
994-
1004+
%
1005+
\begin{center}
1006+
\href{https://github.com/matplotlib/cheatsheets}{Matplotlib Cheatsheets} (c) 2020 Nicolas P. Rougier\\
1007+
Released under a CC-BY 4.0 International License\\
1008+
\smallskip
1009+
\includegraphics[width=\columnwidth]{numfocus.png}
1010+
\end{center}
1011+
9951012
\end{multicols*}
9961013
\end{document}
9971014

File renamed without changes.
File renamed without changes.

icons/github.png

22.6 KB
Loading

icons/github.svg

Lines changed: 57 additions & 0 deletions
Loading
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)