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
+30-29Lines changed: 30 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -348,6 +348,7 @@ The outputs look the same for both of these examples because the plot type was c
348
348
349
349
350
350
.. admonition:: Subplots and Subplot Mosaics
351
+
:collapsible: open
351
352
352
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. 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:
353
354
@@ -369,35 +370,35 @@ The outputs look the same for both of these examples because the plot type was c
369
370
.. admonition:: Mathtext and String Insertion (Not covered by Matplotlib documentation)
370
371
:collapsible:
371
372
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.
373
-
374
-
- LaTeX may need to be installed separately for Matplotlib versions earlier than 3.7, or for exceptionally obscure symbols or odd-sized delimiters.
375
-
376
-
Unfortunately, Python and LaTeX both use curly braces (``{}``) as parts of different functions, so some awkward adjustments had to be made to resolve the collision. *Matplotlib documentation does not cover this.*
377
-
378
-
- In ``str.format()``, **all** curly braces (``{}``) associated with LaTeX commands must be doubled (``{{}}``), including nested braces. *An odd-numbered set of nested curly brace pairs will be interpreted as a site for string insertion.*
379
-
- Many characters also require the whole string to have an ``r`` (for raw input) in front of the first single- or double-quote, like :math:`\times` (rendered as ``'$\times$'``), :math:`\pm` or :math:`\mp`\ (rendered as ``'$\pm$'`` and ``'$\mp$'`` respectively), or some less-used Greek letters.
380
-
- Most basic operator symbols (+, -, /, >, <, !, :, \|, [], ()) can be used as-is, but some that have functional meanings in LaTeX, Python, or both (e.g. ``$`` and ``%``) must be preceded by a single- (LaTeX command symbols only) or double-backslash (``\\``) to escape their typical usage.
381
-
- Spaces within any character sequence between two ``$`` signs are not rendered; they only exist to separate alphabetic characters from commands. You can insert a space with ``\;`` if you don't want to split up the LaTeX sequence to add spaces.
382
-
383
-
You *can* use string insertion inside of formatting operators like the super- and subscript commands, but it can require a *lot* of sequential curly braces. The following is an example demonstrating some tricky typesetting. Note that you generally *cannot split the string text over multiple lines* because the backslash has other essential uses to the typesetting.
384
-
385
-
.. jupyter-execute::
386
-
387
-
import numpy as np
388
-
import matplotlib.pyplot as plt
389
-
%matplotlib inline
390
-
v_init=15.1
391
-
error_arr=[-0.4,0.3]
392
-
fig,ax=plt.subplots(dpi=120,figsize=(5,5))
393
-
ax.set_aspect('equal') #arrowheads look ugly if axes are not equal
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.
374
+
375
+
- LaTeX may need to be installed separately for Matplotlib versions earlier than 3.7, or for exceptionally obscure symbols or odd-sized delimiters.
376
+
377
+
Unfortunately, Python and LaTeX both use curly braces (``{}``) as parts of different functions, so some awkward adjustments had to be made to resolve the collision. *Matplotlib documentation does not cover this.*
378
+
379
+
- In ``str.format()``, **all** curly braces (``{}``) associated with LaTeX commands must be doubled (``{{}}``), including nested braces. *An odd-numbered set of nested curly brace pairs will be interpreted as a site for string insertion.*
380
+
- Many characters also require the whole string to have an ``r`` (for raw input) in front of the first single- or double-quote, like :math:`\times` (rendered as ``'$\times$'``), :math:`\pm` or :math:`\mp`\ (rendered as ``'$\pm$'`` and ``'$\mp$'`` respectively), or some less-used Greek letters.
381
+
- Most basic operator symbols (+, -, /, >, <, !, :, \|, [], ()) can be used as-is, but some that have functional meanings in LaTeX, Python, or both (e.g. ``$`` and ``%``) must be preceded by a single- (LaTeX command symbols only) or double-backslash (``\\``) to escape their typical usage.
382
+
- Spaces within any character sequence between two ``$`` signs are not rendered; they only exist to separate alphabetic characters from commands. You can insert a space with ``\;`` if you don't want to split up the LaTeX sequence to add spaces.
383
+
384
+
You *can* use string insertion inside of formatting operators like the super- and subscript commands, but it can require a *lot* of sequential curly braces. The following is an example demonstrating some tricky typesetting. Note that you generally *cannot split the string text over multiple lines* because the backslash has other essential uses to the typesetting.
385
+
386
+
.. jupyter-execute::
387
+
388
+
import numpy as np
389
+
import matplotlib.pyplot as plt
390
+
%matplotlib inline
391
+
v_init=15.1
392
+
error_arr=[-0.4,0.3]
393
+
fig,ax=plt.subplots(dpi=120,figsize=(5,5))
394
+
ax.set_aspect('equal') #arrowheads look ugly if axes are not equal
0 commit comments