You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/day3/new-matplotlib-intro.rst
+19-44Lines changed: 19 additions & 44 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -347,51 +347,26 @@ The outputs look the same for both of these examples because the plot type was c
347
347
plt.show()
348
348
349
349
350
-
Subplots
351
-
~~~~~~~~
350
+
.. admonition:: Subplots and Subplot Mosaics
352
351
353
-
A prime example of a feature only available through the explicit API is subplots, which support and format 2 or more separate sets of axes on the same figure. For the standard ``fig, ax = plt.subplots(nrows=nrows, ncols=ncols)`` command, the shape of ``ax`` will be
354
-
355
-
* 2D if both ``nrows`` and ``ncols`` are given,
356
-
* 1D if only one of either ``nrows`` or ``ncols`` is provided, or
357
-
* 0D (not iterable) if neither are given.
358
-
359
-
.. jupyter-execute::
360
-
361
-
import numpy as np
362
-
import matplotlib.pyplot as plt
363
-
%matplotlib inline
364
-
x = np.linspace(0,2*np.pi, 50)
365
-
fig, ax = plt.subplots(nrows=2, sharex=True)
366
-
fig.subplots_adjust(hspace=0.05) #reduces space between 2 plots
Other subplot creation functions are available if you need more flexibility between subplots in terms of formatting and coordinate projections. Generally, all methods support shared axes and allow non-Cartesian coordinate projections, but not all methods allow varying projections per plot, and only a couple include support for row- or column-spanning subplots.
377
-
378
-
The following table summarizes all the available subplot creation methods and their capabilities:
\*Note: ``plt.subplot_mosaic()`` is recommended over ``plt.subplot2grid()``.
393
-
394
-
.. admonition:: Mathtext and String Insertion
352
+
A prime example of a feature only available through the explicit API is subplots, which support and format 2 or more separate sets of axes on the same figure. The `Matplotlib documentation on subplots and subplot mosaics <https://matplotlib.org/stable/users/explain/axes/arranging_axes.html>`__ is extensive and fairly straightforward, so this topic will not be covered in depth here. The table below summarizes all the available subplot creation methods that you may see and their capabilities so you can compare them:
\*Note: ``plt.subplot_mosaic()`` is recommended over ``plt.subplot2grid()``.
367
+
368
+
369
+
.. admonition:: Mathtext and String Insertion (Not covered by Matplotlib documentation)
395
370
:collapsible:
396
371
397
372
Most journals expect that you typeset all variables and math scripts so they appear the same in your plots as in your main text, whether those symbols appear in the `axes labels, function labels, plot titles, or annotations. <https://matplotlib.org/stable/users/explain/text/text_intro.html>`__ Matplotlib now `supports most LaTeX math commands, <https://matplotlib.org/stable/users/explain/text/mathtext.html#mathtext>`__ but you need to know some basic LaTeX syntax, some of which is covered in that link. For more information, you can refer to `the WikiBooks documentation on LaTeX math <https://en.wikibooks.org/wiki/LaTeX/Mathematics>`__, starting with the Symbols section.
0 commit comments