Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 08a8499

Browse files
committed
DOC: add details about mathtext.fontset
1 parent 570fe32 commit 08a8499

1 file changed

Lines changed: 50 additions & 2 deletions

File tree

doc/users/dflt_style_changes.rst

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ There is no API level control of the hacth linewidth.
452452
Fonts
453453
=====
454454

455+
Normal text
456+
-----------
457+
455458
The default font has changed from "Bitstream Vera Sans" to "DejaVu
456459
Sans". "DejaVu Sans" is an improvement on "Bistream Vera Sans" that
457460
adds more international and math characters, but otherwise has the
@@ -484,12 +487,57 @@ sub-set of emoji symbols
484487
See the `DejaVu Sans PDF sample for full coverage
485488
<http://dejavu.sourceforge.net/samples/DejaVuSans.pdf>`__.
486489

490+
Math text
491+
---------
492+
487493
The default math font when using the built-in math rendering engine
488494
(mathtext) has changed from "Computer Modern" (i.e. LaTeX-like) to
489-
"DejaVu Sans". To revert to the old behavior, set the ``rcParam``
490-
``mathtext.fontset`` to ``cm``. This change has no effect if the
495+
"DejaVu Sans". This change has no effect if the
491496
TeX backend is used (i.e. ``text.usetex`` is ``True``).
492497

498+
499+
.. plot::
500+
501+
import matplotlib.pyplot as plt
502+
import matplotlib as mpl
503+
504+
mpl.rcParams['mathtext.fontset'] = 'cm'
505+
506+
fig, ax = plt.subplots(tight_layout=True, figsize=(3, 3))
507+
508+
ax.plot(range(15), label='int: $15 \int_0^\infty dx$')
509+
ax.legend()
510+
ax.set_title('classic')
511+
512+
513+
.. plot::
514+
515+
import matplotlib.pyplot as plt
516+
import matplotlib as mpl
517+
518+
fig, ax = plt.subplots(tight_layout=True, figsize=(3, 3))
519+
520+
ax.plot(range(15), label='int: $15 \int_0^\infty dx$')
521+
ax.legend()
522+
ax.set_title('v2.0')
523+
524+
525+
526+
To revert to the old behavior set the::
527+
528+
mpl.rcParams['mathtext.fontset'] = 'cm'
529+
530+
or by setting::
531+
532+
mathetxt.fontset: cm
533+
534+
in your :file:`matplotlibrc` file.
535+
536+
This ``rcParam`` is consulted when the text is drawn, not when the
537+
artist is created. Thus all mathtext on a given ``canvas`` will use the
538+
same fontset.
539+
540+
493541
Legends
494542
=======
495543

0 commit comments

Comments
 (0)