View all fonts supported by JupyterLab in the current system

from matplotlib.font_manager import FontManager

mpl_fonts = set(f.name for f in FontManager().ttflist)

print('all font list get from matplotlib.font_manager:')
for f in sorted(mpl_fonts):
    print('\t' + f)
Copy the code

The print result is as follows:

Just choose a Chinese font. In this case, I chose Apple’s hollyblack font: “Hiragino Sans GB”. Windows users can choose the black font (SimHei).

Deleting cached Files

Mac:

  • cd ~/.matplotlib
    rm -r *
    Copy the code

Windows:

  • Go to your own user directory folder and select “Show hidden files and directories” in the view TAB of Resource Manager to view the. Matplotlib folder, or manually enter the path in the path bar of Resource Manager and press Enter to enter the folder

  • Then delete the resources in this folder.

Example Modify the matplotLibrc configuration file

Mac:

  • Enter the vim ~ /. Matplotlib/matplotlibrc:

    Then change the contents of the file to:

    font.family         : sans-serif
    font.sans-serif         : Hiragino Sans GB
    axes.unicode_minus  : False
    Copy the code

    Font. Sans-serif is the font of your choice.

Win:

  • in.matplotlibCreate a new matplotLibrc file in the folder and paste the above content into it.txtDelete the suffix.

Restart the JupyterLab kernel

Then restart the JupyterLab kernel to see the effect.