|
16 | 16 | % --- Graphics ----------------------------------------------------------------
|
17 | 17 | \usepackage{tikz}
|
18 | 18 | \usepackage{graphicx}
|
19 |
| -\graphicspath{{./figures/}} |
| 19 | +\graphicspath{{./figures/}{./icons/}{./logos/}} |
20 | 20 | \usepackage[export]{adjustbox}
|
21 | 21 |
|
22 | 22 | % --- Framed boxes ------------------------------------------------------------
|
|
250 | 250 |
|
251 | 251 | \begin{multicols*}{5}
|
252 | 252 |
|
253 |
| - \includegraphics[width=\columnwidth]{logo.pdf} |
| 253 | + \includegraphics[width=\columnwidth]{matplotlib.pdf} |
254 | 254 | %\textbf{\Large \RobotoCon Matplotlib 3.2 cheat sheet}\\
|
255 | 255 | %{\ttfamily https://matplotlib.org} \hfill CC-BY 4.0
|
256 | 256 | % \bigskip
|
|
304 | 304 |
|
305 | 305 | % --- Getting help ----------------------------------------------------------
|
306 | 306 | \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}\\ |
307 | 313 | \includegraphics[height=.75em]{discourse.pdf}
|
308 | 314 | \href{https://discourse.matplotlib.org}
|
309 | 315 | {discourse.matplotlib.org}\\
|
|
776 | 782 | %
|
777 | 783 | \vspace{\fill}
|
778 | 784 | %
|
779 |
| - \begin{myboxed}{Text aligmnents \hfill |
| 785 | + \begin{myboxed}{Text alignments \hfill |
780 | 786 | \API{https://matplotlib.org/tutorials/text/text_props.html} }
|
781 | 787 | plt.\textbf{text}( …, ha=… , va=…, … )\\
|
782 | 788 |
|
|
886 | 892 |
|
887 | 893 |
|
888 | 894 |
|
889 |
| - \begin{myboxed}{Color names} |
| 895 | + \begin{myboxed}{Color names \hfill |
| 896 | + \API{https://matplotlib.org/api/colors_api.html} } |
890 | 897 | \includegraphics[width=\columnwidth]{colornames.pdf}
|
891 | 898 | \end{myboxed}
|
892 | 899 | %
|
893 | 900 | \vspace{\fill}
|
894 | 901 | %
|
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=…)\\ |
898 | 907 | \includegraphics[width=\columnwidth]{interpolations.pdf}
|
899 | 908 | \end{myboxed}
|
900 | 909 |
|
|
941 | 950 | \hspace*{2.5mm}~$\rightarrow$ ax.set\_xticks([])\\
|
942 | 951 | \textbf{… remove tick labels ?}\\
|
943 | 952 | \hspace*{2.5mm}~$\rightarrow$ ax.set\_[xy]ticklabels([])\\
|
| 953 | + \textbf{… rotate tick labels ?}\\ |
| 954 | + \hspace*{2.5mm}~$\rightarrow$ plt.[xy]ticks(rotation=90)\\ |
944 | 955 | \textbf{… hide top spine?}\\
|
945 | 956 | \hspace*{2.5mm}~$\rightarrow$ ax.spines['top'].set\_visible(False)\\
|
946 | 957 | \textbf{… hide legend border?}\\
|
|
958 | 969 | \textbf{… get a reversed colormap?}\\
|
959 | 970 | \hspace*{2.5mm}~$\rightarrow$ plt.get\_cmap(``viridis\_r'')\\
|
960 | 971 | \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) |
964 | 975 | \end{myboxed}
|
965 | 976 | %
|
966 | 977 | \vspace{\fill}
|
967 | 978 | %
|
968 | 979 | \begin{myboxed}{Performance tips}
|
| 980 | + \smallskip |
969 | 981 | {\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\\ |
972 | 984 | \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 | + } |
982 | 991 | \end{myboxed}
|
983 | 992 | %
|
984 | 993 | \vspace{\fill}
|
985 | 994 | %
|
986 | 995 | \begin{myboxed}{Beyond Matplotlib}
|
| 996 | + \smallskip |
987 | 997 | \href{https://seaborn.pydata.org/}{\textbf{Seaborn}}: Statistical Data Visualization\\
|
988 | 998 | \href{https://scitools.org.uk/cartopy/docs/latest/}{\textbf{Cartopy}}: Geospatial Data Processing\\
|
989 | 999 | \href{https://yt-project.org/doc/index.html}{\textbf{yt}}: Volumetric data Visualization\\
|
990 | 1000 | \href{https://mpld3.github.io}{\textbf{mpld3}}: Bringing Matplotlib to the browser\\
|
991 | 1001 | \href{https://datashader.org/}{\textbf{Datashader}}: Large data processing pipeline\\
|
992 | 1002 | \href{https://plotnine.readthedocs.io/en/latest/}{\textbf{plotnine}}: A Grammar of Graphics for Python
|
993 | 1003 | \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 | + |
995 | 1012 | \end{multicols*}
|
996 | 1013 | \end{document}
|
997 | 1014 |
|
0 commit comments