|
1 | 1 | % -----------------------------------------------------------------------------
|
2 |
| -% Matplotlib cheat sheet |
3 |
| -% Released under the BSD License |
| 2 | +% Matplotlib cheat sheet - Released under the BSD License |
4 | 3 | % -----------------------------------------------------------------------------
|
5 | 4 | \documentclass[10pt,landscape,a4paper]{article}
|
6 | 5 | \usepackage[utf8]{inputenc}
|
|
246 | 245 | \includegraphics[width=\columnwidth]{logo.pdf}
|
247 | 246 | %\textbf{\Large \RobotoCon Matplotlib 3.2 cheat sheet}\\
|
248 | 247 | %{\ttfamily https://matplotlib.org} \hfill CC-BY 4.0
|
249 |
| - %\bigskip |
| 248 | + % \bigskip |
250 | 249 | \vspace{\fill}
|
| 250 | + %\hspace{1mm} \small \url{https://matplotlib.org/} |
| 251 | + %\vspace{\fill} |
251 | 252 |
|
252 | 253 | % --- Quick start -----------------------------------------------------------
|
253 | 254 | \begin{myboxed}{Quick start \hfill
|
|
274 | 275 | \includegraphics[width=\columnwidth]{anatomy.pdf}
|
275 | 276 | \end{myboxed}
|
276 | 277 | \vspace{\fill}
|
277 |
| - |
278 | 278 | % --- Layout ---------------------------------------------------------------
|
279 | 279 | \begin{myboxed}{Subplots layout \hfill
|
280 | 280 | \API{https://matplotlib.org/tutorials/intermediate/gridspec.html} }
|
|
318 | 318 | \begin{myboxed}{Basic plots}
|
319 | 319 | \plot{basic-plot.pdf}{\textbf{plot}([X],Y,[fmt],…)}
|
320 | 320 | {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}} |
327 | 327 | {}
|
328 | 328 | \plot{basic-scatter.pdf}{\textbf{scatter}(X,Y,…)}
|
329 | 329 | {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}} |
331 | 336 | {}
|
332 | 337 | \plot{basic-bar.pdf}{\textbf{bar[h]}(x,height,…)}
|
333 | 338 | {https://matplotlib.org/api/_as_gen/matplotlib.pyplot.bar.html}
|
|
339 | 344 | \optional{color} }{}
|
340 | 345 | \plot{basic-imshow.pdf}{\textbf{imshow}(Z,[cmap],…)}
|
341 | 346 | {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} } |
343 | 352 | {}
|
344 |
| - \plot{basic-contour.pdf}{\textbf{contour[f]}(Z,[n],…)} |
| 353 | + \plot{basic-contour.pdf}{\textbf{contour[f]}([X],[Y],Z,,…)} |
345 | 354 | {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} } |
347 | 362 | {}
|
348 |
| - \plot{basic-quiver.pdf}{\textbf{quiver}(X,Y,U,V,…)} |
| 363 | + \plot{basic-quiver.pdf}{\textbf{quiver}([X],[Y],U,V,…)} |
349 | 364 | {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} } |
351 | 372 | {}
|
352 |
| - \plot{basic-pie.pdf}{\textbf{pie}(Z,[n],…)} |
| 373 | + \plot{basic-pie.pdf}{\textbf{pie}(X,[explode],…)} |
353 | 374 | {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}} |
355 | 380 | {}
|
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} } |
359 | 391 | {}
|
360 |
| - \plot{basic-fill.pdf}{\textbf{fill[\_between][x]}(…)} |
| 392 | + \plot{basic-fill.pdf}{\textbf{fill[\_between][x]}( … )} |
361 | 393 | {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} } |
363 | 399 | {}
|
364 | 400 | \end{myboxed}
|
365 | 401 | \vspace{\fill}
|
366 | 402 | % --- Advanced plots --------------------------------------------------------
|
367 | 403 | \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} } |
371 | 412 | {}
|
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} } |
375 | 420 | {}
|
376 |
| - \plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,E,…)} |
| 421 | + \plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,xerr,yerr,…)} |
377 | 422 | {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} } |
379 | 428 | {}
|
380 |
| - \plot{advanced-hist.pdf}{\textbf{hist}(X,bins,…)} |
| 429 | + \plot{advanced-hist.pdf}{\textbf{hist}(X, bins, …)} |
381 | 430 | {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}} |
383 | 436 | {}
|
384 | 437 | \plot{advanced-violin.pdf}{\textbf{violinplot}(D,…)}
|
385 | 438 | {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} } |
387 | 443 | {}
|
388 |
| - \plot{advanced-barbs.pdf}{\textbf{barbs}([X],[Y],U,V,…)} |
| 444 | + \plot{advanced-barbs.pdf}{\textbf{barbs}([X],[Y], U, V, …)} |
389 | 445 | {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} } |
391 | 454 | {}
|
392 | 455 | \plot{advanced-event.pdf}{\textbf{eventplot}(positions,…)}
|
393 | 456 | {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} } |
395 | 460 | {}
|
396 | 461 | \plot{advanced-hexbin.pdf}{\textbf{hexbin}(X,Y,C,…)}
|
397 | 462 | {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} } |
399 | 468 | {}
|
400 | 469 | \plot{advanced-xcorr.pdf}{\textbf{xcorr}(X,Y,…)}
|
401 | 470 | {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} } |
403 | 475 | {}
|
404 | 476 | \end{myboxed}
|
405 | 477 |
|
|
460 | 532 | \API{https://matplotlib.org/tutorials/colors/colors.html}}
|
461 | 533 | % mpl.colors.to\_rbga(\textbf{color})\smallskip\\
|
462 | 534 | \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}@{}} |
464 | 536 | \palette{cycle}{'Cn'}
|
465 | 537 | \palette{raw}{ 'x' }
|
466 | 538 | \palette{name}{'name'}
|
|
479 | 551 | \API{https://matplotlib.org/tutorials/colors/colormaps.html}}
|
480 | 552 | {\ttfamily plt.\textbf{get\_cmap}(name) \smallskip\\}
|
481 | 553 | \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}@{}} |
483 | 555 | \scriptsize \rule{0pt}{1.25em}Uniform & \\
|
484 | 556 | \colormap{viridis} \colormap{magma} \colormap{plasma}
|
485 | 557 | %
|
|
537 | 609 | %
|
538 | 610 | {\ttfamily ax.\textbf{annotate}(…)} \hfill
|
539 | 611 | \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}\\ |
542 | 620 | %
|
543 | 621 | \end{myboxed}
|
544 | 622 | %
|
|
0 commit comments