Skip to content

Commit da85c51

Browse files
committed
Updated function parameters
1 parent ff75c70 commit da85c51

File tree

3 files changed

+154
-44
lines changed

3 files changed

+154
-44
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1-
fonts*
1+
fonts*
2+
*.upa
3+
*.log
4+
*.out
5+
*.aux

cheatsheet-basic.tex

Lines changed: 121 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
% -----------------------------------------------------------------------------
2-
% Matplotlib cheat sheet
3-
% Released under the BSD License
2+
% Matplotlib cheat sheet - Released under the BSD License
43
% -----------------------------------------------------------------------------
54
\documentclass[10pt,landscape,a4paper]{article}
65
\usepackage[utf8]{inputenc}
@@ -246,8 +245,10 @@
246245
\includegraphics[width=\columnwidth]{logo.pdf}
247246
%\textbf{\Large \RobotoCon Matplotlib 3.2 cheat sheet}\\
248247
%{\ttfamily https://matplotlib.org} \hfill CC-BY 4.0
249-
%\bigskip
248+
% \bigskip
250249
\vspace{\fill}
250+
%\hspace{1mm} \small \url{https://matplotlib.org/}
251+
%\vspace{\fill}
251252

252253
% --- Quick start -----------------------------------------------------------
253254
\begin{myboxed}{Quick start \hfill
@@ -274,7 +275,6 @@
274275
\includegraphics[width=\columnwidth]{anatomy.pdf}
275276
\end{myboxed}
276277
\vspace{\fill}
277-
278278
% --- Layout ---------------------------------------------------------------
279279
\begin{myboxed}{Subplots layout \hfill
280280
\API{https://matplotlib.org/tutorials/intermediate/gridspec.html} }
@@ -318,16 +318,21 @@
318318
\begin{myboxed}{Basic plots}
319319
\plot{basic-plot.pdf}{\textbf{plot}([X],Y,[fmt],…)}
320320
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.plot.html}
321-
{\paramx{optional},
322-
\paramy{mandatory},
323-
\paramfmt{optional},
324-
\paramcolor{optional},
325-
\parammarker{optional},
326-
\paramlinestyle{optional}}
321+
{\optional{X},
322+
\mandatory{Y},
323+
\optional{fmt},
324+
\optional{color},
325+
\optional{marker},
326+
\optional{linestyle}}
327327
{}
328328
\plot{basic-scatter.pdf}{\textbf{scatter}(X,Y,…)}
329329
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.scatter.html}
330-
{x, y, [s]izes, [c]olors, markers, cmap}
330+
{\mandatory{X},
331+
\mandatory{Y},
332+
\optional{[s]izes},
333+
\optional{[c]olors},
334+
\optional{markers},
335+
\optional{cmap}}
331336
{}
332337
\plot{basic-bar.pdf}{\textbf{bar[h]}(x,height,…)}
333338
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html}
@@ -339,67 +344,134 @@
339344
\optional{color} }{}
340345
\plot{basic-imshow.pdf}{\textbf{imshow}(Z,[cmap],…)}
341346
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html}
342-
{\Z, \cmap, \interpolation{optional}, \extent, \origin}
347+
{ \mandatory{Z},
348+
\optional{cmap},
349+
\optional{interpolation},
350+
\optional{extent},
351+
\optional{origin} }
343352
{}
344-
\plot{basic-contour.pdf}{\textbf{contour[f]}(Z,[n],…)}
353+
\plot{basic-contour.pdf}{\textbf{contour[f]}([X],[Y],Z,,…)}
345354
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.contour.html}
346-
{z, n, colors, extents, origin}
355+
{ \optional{X},
356+
\optional{Y},
357+
\mandatory{Z},
358+
\optional{levels},
359+
\optional{colors},
360+
\optional{extent},
361+
\optional{origin} }
347362
{}
348-
\plot{basic-quiver.pdf}{\textbf{quiver}(X,Y,U,V,…)}
363+
\plot{basic-quiver.pdf}{\textbf{quiver}([X],[Y],U,V,…)}
349364
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.quiver.html}
350-
{x, y, fmt, color, marker, linestyle}
365+
{ \optional{X},
366+
\optional{Y},
367+
\mandatory{U},
368+
\mandatory{V},
369+
\optional{C},
370+
\optional{units},
371+
\optional{angles} }
351372
{}
352-
\plot{basic-pie.pdf}{\textbf{pie}(Z,[n],…)}
373+
\plot{basic-pie.pdf}{\textbf{pie}(X,[explode],…)}
353374
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html}
354-
{z, n, colors, extents, origin}
375+
{\mandatory{Z},
376+
\optional{explode},
377+
\optional{labels},
378+
\optional{colors},
379+
\optional{radius}}
355380
{}
356-
\plot{basic-text.pdf}{\textbf{text}(X,Y,text,…)}
357-
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html}
358-
{ha, va, size, weight, family, transform}
381+
\plot{basic-text.pdf}{\textbf{text}(x,y,text,…)}
382+
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.text.html}
383+
{\mandatory{x},
384+
\mandatory{y},
385+
\mandatory{text},
386+
\optional{va},
387+
\optional{ha},
388+
\optional{size},
389+
\optional{weight},
390+
\optional{transform} }
359391
{}
360-
\plot{basic-fill.pdf}{\textbf{fill[\_between][x]}()}
392+
\plot{basic-fill.pdf}{\textbf{fill[\_between][x]}()}
361393
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.pie.html}
362-
{}
394+
{\mandatory{X},
395+
\optional{Y1},
396+
\optional{Y2},
397+
\optional{color},
398+
\optional{where} }
363399
{}
364400
\end{myboxed}
365401
\vspace{\fill}
366402
% --- Advanced plots --------------------------------------------------------
367403
\begin{myboxed}{Advanced plots}
368-
\plot{advanced-step.pdf}{\textbf{step}([X],Y,[fmt],…)}
369-
{https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.violinplot.html}
370-
{x, y, fmt, color, marker, linestyle}
404+
\plot{advanced-step.pdf}{\textbf{step}(X,Y,[fmt],…)}
405+
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.step.html}
406+
{\mandatory{X},
407+
\mandatory{Y},
408+
\optional{fmt},
409+
\optional{color},
410+
\optional{marker},
411+
\optional{where} }
371412
{}
372-
\plot{advanced-boxplot.pdf}{\textbf{boxplot}(D,…)}
373-
{https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.violinplot.html}
374-
{x, y, fmt, color, marker, linestyle}
413+
\plot{advanced-boxplot.pdf}{\textbf{boxplot}(X,…)}
414+
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.boxplot.html}
415+
{ \mandatory{X},
416+
\optional{notch},
417+
\optional{sym},
418+
\optional{bootstrap},
419+
\optional{widths} }
375420
{}
376-
\plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,E,…)}
421+
\plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,xerr,yerr,…)}
377422
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.errorbar.html}
378-
{x, y, fmt, color, marker, linestyle}
423+
{ \mandatory{X},
424+
\mandatory{Y},
425+
\optional{xerr},
426+
\optional{yerr},
427+
\optional{fmt} }
379428
{}
380-
\plot{advanced-hist.pdf}{\textbf{hist}(X,bins,…)}
429+
\plot{advanced-hist.pdf}{\textbf{hist}(X, bins, …)}
381430
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hist.html}
382-
{x, y, fmt, color, marker, linestyle}
431+
{\mandatory{X},
432+
\optional{bins},
433+
\optional{range},
434+
\optional{density},
435+
\optional{weights}}
383436
{}
384437
\plot{advanced-violin.pdf}{\textbf{violinplot}(D,…)}
385438
{https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.violinplot.html}
386-
{x, y, fmt, color, marker, linestyle}
439+
{\mandatory{D},
440+
\optional{positions},
441+
\optional{widths},
442+
\optional{vert} }
387443
{}
388-
\plot{advanced-barbs.pdf}{\textbf{barbs}([X],[Y],U,V,…)}
444+
\plot{advanced-barbs.pdf}{\textbf{barbs}([X],[Y], U, V, …)}
389445
{https://matplotlib.org/api/_as_gen/matplotlib.axes.Axes.violinplot.html}
390-
{x, y, fmt, color, marker, linestyle}
446+
{ \optional{X},
447+
\optional{Y},
448+
\mandatory{U},
449+
\mandatory{V},
450+
\optional{C},
451+
\optional{length},
452+
\optional{pivot},
453+
\optional{sizes} }
391454
{}
392455
\plot{advanced-event.pdf}{\textbf{eventplot}(positions,…)}
393456
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.eventplot.html}
394-
{x, y, fmt, color, marker, linestyle}
457+
{\mandatory{positions},
458+
\optional{orientation},
459+
\optional{lineoffsets} }
395460
{}
396461
\plot{advanced-hexbin.pdf}{\textbf{hexbin}(X,Y,C,…)}
397462
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.hexbin.html}
398-
{x, y, fmt, color, marker, linestyle}
463+
{\mandatory{X},
464+
\mandatory{Y},
465+
\optional{C},
466+
\optional{gridsize},
467+
\optional{bins} }
399468
{}
400469
\plot{advanced-xcorr.pdf}{\textbf{xcorr}(X,Y,…)}
401470
{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.xcorr.html}
402-
{x, y, fmt, color, marker, linestyle}
471+
{\mandatory{X},
472+
\mandatory{Y},
473+
\optional{normed},
474+
\optional{detrend} }
403475
{}
404476
\end{myboxed}
405477

@@ -460,7 +532,7 @@
460532
\API{https://matplotlib.org/tutorials/colors/colors.html}}
461533
% mpl.colors.to\_rbga(\textbf{color})\smallskip\\
462534
\def\arraystretch{0.5}
463-
\begin{tabular}{@{}p{0.7\columnwidth}p{0.3\columnwidth}@{}}
535+
\begin{tabular}{@{}p{0.7\columnwidth}p{0.25\columnwidth}@{}}
464536
\palette{cycle}{'Cn'}
465537
\palette{raw}{ 'x' }
466538
\palette{name}{'name'}
@@ -479,7 +551,7 @@
479551
\API{https://matplotlib.org/tutorials/colors/colormaps.html}}
480552
{\ttfamily plt.\textbf{get\_cmap}(name) \smallskip\\}
481553
\def\arraystretch{0.5}
482-
\begin{tabular}{@{}p{0.7\columnwidth}p{0.3\columnwidth}@{}}
554+
\begin{tabular}{@{}p{0.7\columnwidth}p{0.25\columnwidth}@{}}
483555
\scriptsize \rule{0pt}{1.25em}Uniform & \\
484556
\colormap{viridis} \colormap{magma} \colormap{plasma}
485557
%
@@ -537,8 +609,14 @@
537609
%
538610
{\ttfamily ax.\textbf{annotate}(…)} \hfill
539611
\api{https://matplotlib.org/api/_as_gen/matplotlib.pyplot.annotate.html}\\
540-
mappable, ax, cax, orientation \smallskip\\
541-
\includegraphics[width=\columnwidth]{colorbar.pdf}\\
612+
\mandatory{text},
613+
\mandatory{xy},
614+
\mandatory{xytext},
615+
\optional{xycoords},
616+
\optional{textcoords},
617+
\optional{arrowprops}
618+
\smallskip\\
619+
\includegraphics[width=\columnwidth]{annotate.pdf}\\
542620
%
543621
\end{myboxed}
544622
%

scripts/annotate.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# -----------------------------------------------------------------------------
2+
# Matplotlib cheat sheet
3+
# Released under the BSD License
4+
# -----------------------------------------------------------------------------
5+
import numpy as np
6+
import matplotlib as mpl
7+
import matplotlib.pyplot as plt
8+
9+
10+
fig = plt.figure(figsize=(6,1))
11+
#ax = plt.subplot(111, frameon=False, aspect=.1)
12+
# b = 0.0
13+
ax = fig.add_axes([0,0,1,1], frameon=False, aspect=1)
14+
15+
16+
17+
plt.scatter([5.5],[0.75], s=100, c="k")
18+
plt.xlim(0,6), plt.ylim(0,1)
19+
plt.xticks([]), plt.yticks([])
20+
21+
plt.annotate("Annotation", (5.5,.75), (0.1,.75), size=16, va="center",
22+
arrowprops=dict(facecolor='black', shrink=0.05))
23+
24+
plt.text( 5.5, 0.6, "xy\nycoords", size=10, va="top", ha="center", color=".5")
25+
plt.text( .75, 0.6, "xytext\ntextcoords", size=10, va="top", ha="center", color=".5")
26+
27+
plt.savefig("../figures/annotate.pdf")
28+
# plt.show()

0 commit comments

Comments
 (0)