Font friends can go to my public number [thumb notes], background reply: SimHei, self.

Resolve the jupyter Notebook Matplotlib mapping Chinese garble problem

Recently, I tried to add Chinese title to the drawing, but the square garbled code appeared. Did some research and finally found a solution.

0. The effect is as follows

1. First find the directory of the matplotlib font configuration file.

import matplotlib
matplotlib.matplotlib_fname()
Copy the code

Matplotlibrc: configuration file

Fonts: fonts folder

2. Download SimHei fonts

Need friends can go to my public number [thumb notes], background reply: SimHei, self.

3. Place the downloaded fonts in the fonts\ TTF folder

4. Modify the matplotLibrc configuration file

The editor opens the matplotLibrc file

Uncomment this line (my screenshot is already uncommented)

Uncomment this line and add SimHei after the colon

Uncomment this line as well and change it to True

5. Delete the cache

6. Restart the Jupyter notebook

Finally, Chinese is displayed successfully