Font selection

    Matplotlib provides a module for working with system fonts and classifies fonts into : [rc[‘font.serif’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.serif#the-matplotlibrc-file) [rc[‘font.sans-serif’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.sans-serif#the-matplotlibrc-file), [rc[‘font.monospace’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.monospace#the-matplotlibrc-file), [rc[‘font.cursive’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.cursive#the-matplotlibrc-file), and [rc[‘font.fantasy’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.fantasy#the-matplotlibrc-file). 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.

    Matplotlib uses DejaVu Sans in part because it includes glyphs for a very wide range of symbols, especially mathematical symbols. However DejaVu Sans is seldom used outside of matplotlib and (in our opinion) is not very aesthetically pleasing. To improve the font selection while keeping things consistent across different workstations, ProPlot comes packaged with the open-source and adds them as the default entries for all of matplotlib’s font famlies:

    • The Helvetica lookalike [rc[‘font.sans-serif’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.sans-serif#the-matplotlibrc-file) = 'TeX Gyre Heros'.

    • The lookalike [rc[‘font.fantasy’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.fantasy#the-matplotlibrc-file) = 'TeX Gyre Adventor'.

    Thus after importing ProPlot, the default font will be the more conventional and aesthetically pleasing Helvetica lookalike TeX Gyre Heros. The new font priority lists for each font family are shown in the .

    To compare different fonts, use the show_fonts command. By default, this displays the sans serif fonts available on your system and packaged with ProPlot. The sans serif table on the RTD server is shown below. The “¤” symbol appears where characters for a particular font are unavailable (when making plots, “¤” is replaced with the character from a fallback font). Since most TeX Gyre fonts have limited character sets, if your plots contain lots of mathematical symbols, you may want to set [rc[‘font.family’]](https://matplotlib.org/tutorials/introductory/customizing.html?highlight=font.family#the-matplotlibrc-file) to DejaVu Sans or , which is packaged with ProPlot.

    Try to avoid .ttf files with Thin in the file name. Matplotlib interprets fonts with the “thin” style having normal weight (see this matplotlib issue), causing them to override the correct normal weight versions. While ProPlot tries to filter out these files, this cannot be done systematically. In the below example, the “Roboto” font may be overridden by its “thin” version because the RTD server includes this style.

    1. import proplot as plot

    Using your own fonts

    You can register your own fonts by adding files to the ~/.proplot/fonts directory and calling register_fonts. This command is also called on import. 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 , .otf, or .afm formats. For example, several macOS fonts are unavailable because they are stored as .dfont collections. Also, while matplotlib nominally supports .ttc collections, ProPlot ignores them because figures with .ttc fonts . You can get matplotlib to use .dfont and .ttc collections by expanding them into individual .ttf files with the DFontSplitter application, then saving the files in-place or in the ~/.proplot/fonts folder.