Proplot registers several new fonts and includes tools for adding your own fonts. These features are described below.
Matplotlib provides a
font_manager module for working with
system fonts and classifies fonts into five font families:
rc['font.fantasy']. The default font family
is sans-serif, because sans-serif fonts are generally more suitable for
figures than serif fonts, and the default font name belonging to this family
is DejaVu Sans, which comes packaged with
Matplotlib uses DejaVu Sans in part because it includes glyphs for a very wide range of symbols, especially mathematical symbols. However in our opinion, DejaVu Sans is not very aesthetically pleasing. To improve the font selection while keeping things consistent across different workstations, proplot is packaged the open source TeX Gyre fonts and a few additional open source sans-serif fonts. Proplot also uses the TeX Gyre fonts as the first (i.e., default) entries for each of matplotlib’s font family lists:
The Helvetica lookalike
'TeX Gyre Heros'.
The Century lookalike
'TeX Gyre Schola'.
The Chancery lookalike
'TeX Gyre Chorus'.
The Avant Garde lookalike
'TeX Gyre Adventor'.
The Courier lookalike
'TeX Gyre Cursor'.
After importing proplot, the default matplotlib font will be
TeX Gyre Heros, which
emulates the more conventional and (in our opinion) aesthetically pleasing
font Helvetica. The default font
family lists are shown in the default proplotrc file.
To compare different fonts, use the
show_fonts command with the
family keyword (default behavior is
family='sans-serif'). Tables of the TeX
Gyre and sans-serif fonts packaged with proplot are shown below.
import proplot as pplt fig, axs = pplt.show_fonts(family='sans-serif')
import proplot as pplt fig, axs = pplt.show_fonts(family='tex-gyre')
Math text fonts¶
In matplotlib, math text rendered by TeX can be produced by surrounding
an expression with
$dollar signs$. To help math text jive better with
the new default non-math text font, proplot changes
'custom'. This means that math is drawn with
the italicized version of the non-math font (see the matplotlib math text
for details). This generally improves the appearance of figures with simple
math expressions. However, if you need unusual math symbols or complex math
operators, you may want to change
rc['font.name'] to something more suitable
for math (e.g., the proplot-packaged font
'Fira Math' or the matplotlib-packaged
'DejaVu Sans'; see this page for
more on Fira Math). Alternatively, you can change the math text font alone by setting
rc['mathtext.fontset'] back to one of matplotlib’s math-specialized font sets
A table of math text containing the sans-serif fonts packaged with proplot is shown
below. The dummy glyph “¤” is shown where a given math character is unavailable
for a particular font (in practice, the fallback font
rc['mathtext.fallback'] is used
whenever a math character is unavailable, but
this fallback font in order to highlight the missing characters).
Proplot modifies matplotlib’s math text internals so that the
font set can be applied with modifications to the currently active non-math
font rather than only a global font family. This works by changing the default
rc['mathtext.sf'] from the global default font family
'sans' to the local
'regular' is a dummy name permitted by
proplot (see the proplotrc file for details). This means
'custom' and the font family is changed
for an arbitrary
Text instance, then any LaTeX-generated math
in the text string will also use this font family.
import proplot as pplt fig, axs = pplt.show_fonts(family='sans-serif', math=True)
Using your own fonts¶
You can register your own fonts by adding files to the
user_folder and calling
register_fonts. This command is called on import. You can
also manually pass file paths to
To change the default font, use the
object or modify your
proplotrc. See the
configuration section for details.
Sometimes the font you would like to use is installed, but the font file
is not stored under the matplotlib-compatible
formats. For example, several macOS fonts are unavailable because they are
.dfont collections. Also, while matplotlib nominally supports
.ttc collections, proplot ignores them because figures with
cannot be saved as PDFs.
You can get matplotlib to use
.ttc collections by
expanding them into individual
.ttf files with the
then saving the files in-place or in the
To find font collections, check the paths listed in