First find the MATPLOTLIBRC file modification under D:\Python\Lib\site-packages\matplotlib\mpl-data
1, find
#font. Family:sans-serif
Remove comments
2, find
#font. Sans-serif:bitstream Vera Sans, lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, Sans-ser If
Revision changed to
Font.sans-serif:microsoft Yahei, bitstream Vera sans, lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, Sans-serif removes the comment and adds the Microsoft Yahei to the configuration value
then found under C:\Windows\Fonts Microsoft Black, click in, choose General (Msyh.tty)
copied toD:\Python\Lib\site-packages\matplotlib\mpl-data\fonts\ttf
folder can beFinally add at run codeplt.rcparams[
' font.sans-
serif
' ] = [
' Microsoft Yahei ' ]
Python's matplotlib library drawing does not display Chinese problem resolution