|
301 | 301 | % --- Layout ---------------------------------------------------------------
|
302 | 302 | \begin{myboxed}{Subplots layout \hfill
|
303 | 303 | \API{https://matplotlib.org/tutorials/intermediate/gridspec.html} }
|
304 |
| - \plot{layout-subplot.pdf}{\textbf{subplot[s]}(rows,cols,…)} |
| 304 | + \plot{layout-subplot.pdf}{\textbf{subplot[s]}(rows, cols, …)} |
305 | 305 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.subplots.html}
|
306 | 306 | {\ttfamily fig, axs = plt.subplots(3, 3)}
|
307 | 307 | {}
|
308 |
| - \plot{layout-gridspec.pdf}{G = \textbf{gridspec}(rows,cols,…)} |
| 308 | + \plot{layout-gridspec.pdf}{G = \textbf{gridspec}(rows,cols, …)} |
309 | 309 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.gridspec.GridSpec.html}
|
310 |
| - {\ttfamily ax = G[0,:]}{} |
| 310 | + {\ttfamily ax = G[0, :]}{} |
311 | 311 | \plot{layout-inset.pdf}{ax.\textbf{inset\_axes}(extent)}
|
312 | 312 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.inset_axes.html}
|
313 | 313 | {}{}
|
|
338 | 338 |
|
339 | 339 | % --- Basic plots -----------------------------------------------------------
|
340 | 340 | \begin{myboxed}{Basic plots}
|
341 |
| - \plot{basic-plot.pdf}{\textbf{plot}([X],Y,[fmt],…)} |
| 341 | + \plot{basic-plot.pdf}{\textbf{plot}([X], Y, [fmt], …)} |
342 | 342 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.plot.html}
|
343 | 343 | {\optional{X},
|
344 | 344 | \mandatory{Y},
|
|
347 | 347 | \optional{marker},
|
348 | 348 | \optional{linestyle}}
|
349 | 349 | {}
|
350 |
| - \plot{basic-scatter.pdf}{\textbf{scatter}(X,Y,…)} |
| 350 | + \plot{basic-scatter.pdf}{\textbf{scatter}(X, Y, …)} |
351 | 351 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.scatter.html}
|
352 | 352 | {\mandatory{X},
|
353 | 353 | \mandatory{Y},
|
|
356 | 356 | \optional{marker},
|
357 | 357 | \optional{cmap}}
|
358 | 358 | {}
|
359 |
| - \plot{basic-bar.pdf}{\textbf{bar[h]}(x,height,…)} |
| 359 | + \plot{basic-bar.pdf}{\textbf{bar[h]}(x, height, …)} |
360 | 360 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.bar.html}
|
361 | 361 | { \mandatory{x},
|
362 | 362 | \mandatory{height},
|
363 | 363 | \optional{width},
|
364 | 364 | \optional{bottom},
|
365 | 365 | \optional{align},
|
366 | 366 | \optional{color} }{}
|
367 |
| - \plot{basic-imshow.pdf}{\textbf{imshow}(Z,…)} |
| 367 | + \plot{basic-imshow.pdf}{\textbf{imshow}(Z, …)} |
368 | 368 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.imshow.html}
|
369 | 369 | { \mandatory{Z},
|
370 | 370 | \optional{cmap},
|
371 | 371 | \optional{interpolation},
|
372 | 372 | \optional{extent},
|
373 | 373 | \optional{origin} }
|
374 | 374 | {}
|
375 |
| - \plot{basic-contour.pdf}{\textbf{contour[f]}([X],[Y],Z,…)} |
| 375 | + \plot{basic-contour.pdf}{\textbf{contour[f]}([X], [Y], Z, …)} |
376 | 376 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.contour.html}
|
377 | 377 | { \optional{X},
|
378 | 378 | \optional{Y},
|
|
382 | 382 | \optional{extent},
|
383 | 383 | \optional{origin} }
|
384 | 384 | {}
|
385 |
| - \plot{basic-pcolormesh.pdf}{\textbf{pcolormesh}([X],[Y],Z,…)} |
| 385 | + \plot{basic-pcolormesh.pdf}{\textbf{pcolormesh}([X], [Y], Z, …)} |
386 | 386 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pcolormesh.html}
|
387 | 387 | { \optional{X},
|
388 | 388 | \optional{Y},
|
|
391 | 391 | \optional{vmax},
|
392 | 392 | \optional{cmap}}
|
393 | 393 | {}
|
394 |
| - \plot{basic-quiver.pdf}{\textbf{quiver}([X],[Y],U,V,…)} |
| 394 | + \plot{basic-quiver.pdf}{\textbf{quiver}([X], [Y], U, V, …)} |
395 | 395 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.quiver.html}
|
396 | 396 | { \optional{X},
|
397 | 397 | \optional{Y},
|
|
401 | 401 | \optional{units},
|
402 | 402 | \optional{angles} }
|
403 | 403 | {}
|
404 |
| - \plot{basic-pie.pdf}{\textbf{pie}(X,…)} |
| 404 | + \plot{basic-pie.pdf}{\textbf{pie}(X, …)} |
405 | 405 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.pie.html}
|
406 | 406 | {\mandatory{Z},
|
407 | 407 | \optional{explode},
|
408 | 408 | \optional{labels},
|
409 | 409 | \optional{colors},
|
410 | 410 | \optional{radius}}
|
411 | 411 | {}
|
412 |
| - \plot{basic-text.pdf}{\textbf{text}(x,y,text,…)} |
| 412 | + \plot{basic-text.pdf}{\textbf{text}(x, y, text, …)} |
413 | 413 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.text.html}
|
414 | 414 | {\mandatory{x},
|
415 | 415 | \mandatory{y},
|
|
432 | 432 | \vspace{\fill}
|
433 | 433 | % --- Advanced plots --------------------------------------------------------
|
434 | 434 | \begin{myboxed}{Advanced plots}
|
435 |
| - \plot{advanced-step.pdf}{\textbf{step}(X,Y,[fmt],…)} |
| 435 | + \plot{advanced-step.pdf}{\textbf{step}(X, Y, [fmt], …)} |
436 | 436 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.step.html}
|
437 | 437 | {\mandatory{X},
|
438 | 438 | \mandatory{Y},
|
|
441 | 441 | \optional{marker},
|
442 | 442 | \optional{where} }
|
443 | 443 | {}
|
444 |
| - \plot{advanced-boxplot.pdf}{\textbf{boxplot}(X,…)} |
| 444 | + \plot{advanced-boxplot.pdf}{\textbf{boxplot}(X, …)} |
445 | 445 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.boxplot.html}
|
446 | 446 | { \mandatory{X},
|
447 | 447 | \optional{notch},
|
448 | 448 | \optional{sym},
|
449 | 449 | \optional{bootstrap},
|
450 | 450 | \optional{widths} }
|
451 | 451 | {}
|
452 |
| - \plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,xerr,yerr,…)} |
| 452 | + \plot{advanced-errorbar.pdf}{\textbf{errorbar}(X,Y,xerr,yerr, …)} |
453 | 453 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.errorbar.html}
|
454 | 454 | { \mandatory{X},
|
455 | 455 | \mandatory{Y},
|
|
465 | 465 | \optional{density},
|
466 | 466 | \optional{weights}}
|
467 | 467 | {}
|
468 |
| - \plot{advanced-violin.pdf}{\textbf{violinplot}(D,…)} |
| 468 | + \plot{advanced-violin.pdf}{\textbf{violinplot}(D, …)} |
469 | 469 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.violinplot.html}
|
470 | 470 | {\mandatory{D},
|
471 | 471 | \optional{positions},
|
472 | 472 | \optional{widths},
|
473 | 473 | \optional{vert} }
|
474 | 474 | {}
|
475 |
| - \plot{advanced-barbs.pdf}{\textbf{barbs}([X],[Y], U, V, …)} |
| 475 | + \plot{advanced-barbs.pdf}{\textbf{barbs}([X], [Y], U, V, …)} |
476 | 476 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.barbs.html}
|
477 | 477 | { \optional{X},
|
478 | 478 | \optional{Y},
|
|
483 | 483 | \optional{pivot},
|
484 | 484 | \optional{sizes} }
|
485 | 485 | {}
|
486 |
| - \plot{advanced-event.pdf}{\textbf{eventplot}(positions,…)} |
| 486 | + \plot{advanced-event.pdf}{\textbf{eventplot}(positions, …)} |
487 | 487 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.eventplot.html}
|
488 | 488 | {\mandatory{positions},
|
489 | 489 | \optional{orientation},
|
490 | 490 | \optional{lineoffsets} }
|
491 | 491 | {}
|
492 |
| - \plot{advanced-hexbin.pdf}{\textbf{hexbin}(X,Y,C,…)} |
| 492 | + \plot{advanced-hexbin.pdf}{\textbf{hexbin}(X, Y, C, …)} |
493 | 493 | {https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hexbin.html}
|
494 | 494 | {\mandatory{X},
|
495 | 495 | \mandatory{Y},
|
|
503 | 503 | % --- Scale ---------------------------------------------------------------
|
504 | 504 | \begin{myboxed}{Scales \hfill
|
505 | 505 | \API{https://matplotlib.org/stable/api/scale_api.html}}
|
506 |
| - {\ttfamily ax.\textbf{set\_[xy]scale}(scale,…)} |
| 506 | + {\ttfamily ax.\textbf{set\_[xy]scale}(scale, …)} |
507 | 507 | \smallskip
|
508 | 508 | \scale{scale-linear.pdf}{\textbf{linear}}{any values}
|
509 | 509 | \scale{scale-log.pdf}{\textbf{log}}{values > 0}
|
|
516 | 516 | % --- Projections -----------------------------------------------------------
|
517 | 517 | \begin{myboxed}{Projections \hfill
|
518 | 518 | \API{https://matplotlib.org/stable/api/projections_api.html}}
|
519 |
| - {\ttfamily \textbf{subplot}(…,projection=p)} |
| 519 | + {\ttfamily \textbf{subplot}(…, projection=p)} |
520 | 520 | \smallskip
|
521 | 521 | \scale{projection-polar.pdf}{p='polar'}{}
|
522 | 522 | \scale{projection-3d.pdf}
|
|
906 | 906 |
|
907 | 907 | \begin{myboxed}{Legend placement}
|
908 | 908 | \includegraphics[width=\columnwidth]{legend-placement.pdf}
|
909 |
| - ax.\textbf{legend}(loc="string", bbox\_to\_anchor=(x,y))\\ |
| 909 | + ax.\textbf{legend}(loc="string", bbox\_to\_anchor=(x, y))\\ |
910 | 910 | \begin{tabular}{@{}p{0.33\columnwidth}
|
911 | 911 | p{0.33\columnwidth}
|
912 | 912 | p{0.33\columnwidth}@{}}
|
|
919 | 919 | \begin{tabular}{@{}p{0.495\columnwidth}
|
920 | 920 | p{0.495\columnwidth}@{}}
|
921 | 921 | \scriptsize \rule{0pt}{1.25em}\noindent
|
922 |
| - \tiny A: upper right / {\ttfamily (-0.1,0.9)} & \tiny B: center right / {\ttfamily (-0.1,0.5)}\\ |
923 |
| - \tiny C: lower right / {\ttfamily (-0.1,0.1)} & \tiny D: upper left / {\ttfamily (0.1,-0.1)}\\ |
924 |
| - \tiny E: upper center / {\ttfamily (0.5,-0.1)} & \tiny F: upper right / {\ttfamily (0.9,-0.1)}\\ |
925 |
| - \tiny G: lower left / {\ttfamily (1.1,0.1)} & \tiny H: center left / {\ttfamily (1.1,0.5)}\\ |
926 |
| - \tiny I: upper left / {\ttfamily (1.1,0.9)} & \tiny J: lower right / {\ttfamily (0.9,1.1)}\\ |
927 |
| - \tiny K: lower center / {\ttfamily (0.5,1.1)} & \tiny L: lower left / {\ttfamily (0.1,1.1)} |
| 922 | + \tiny A: upper right / {\ttfamily (-0.1, 0.9)} & \tiny B: center right / {\ttfamily (-0.1, 0.5)}\\ |
| 923 | + \tiny C: lower right / {\ttfamily (-0.1, 0.1)} & \tiny D: upper left / {\ttfamily (0.1, -0.1)}\\ |
| 924 | + \tiny E: upper center / {\ttfamily (0.5, -0.1)} & \tiny F: upper right / {\ttfamily (0.9, -0.1)}\\ |
| 925 | + \tiny G: lower left / {\ttfamily (1.1, 0.1)} & \tiny H: center left / {\ttfamily (1.1, 0.5)}\\ |
| 926 | + \tiny I: upper left / {\ttfamily (1.1, 0.9)} & \tiny J: lower right / {\ttfamily (0.9, 1.1)}\\ |
| 927 | + \tiny K: lower center / {\ttfamily (0.5, 1.1)} & \tiny L: lower left / {\ttfamily (0.1, 1.1)} |
928 | 928 | \end{tabular}
|
929 | 929 | \end{myboxed}
|
930 | 930 | %
|
|
1000 | 1000 | plot(X, Y, marker="o", ls="") \hfill fast%
|
1001 | 1001 | \vskip.5\baselineskip
|
1002 | 1002 | %
|
1003 |
| - \textcolor{red}{for i in range(n): plot(X[i]) \hfill slow}\\ |
1004 |
| - plot(sum([x+[None] for x in X],[])) \hfill fast% |
| 1003 | + \textcolor{red}{for i in range(n): plot(i, X[i], "o") \hfill slow}\\ |
| 1004 | + plot(X, marker="o", ls="") \hfill fast% |
1005 | 1005 | \vskip.5\baselineskip
|
1006 | 1006 | %
|
1007 |
| - \textcolor{red}{cla(), imshow(…), canvas.draw() \hfill slow}\\ |
1008 |
| - im.set\_data(…), canvas.draw() \hfill fast% |
| 1007 | + \textcolor{red}{cla(); imshow(…); canvas.draw() \hfill slow}\\ |
| 1008 | + im.set\_data(…); canvas.draw() \hfill fast% |
1009 | 1009 | \vskip.1\baselineskip
|
1010 | 1010 | }
|
1011 | 1011 | \end{myboxed}
|
|
0 commit comments