python 错误RuntimeWarning: Glyph 22823 missing from current font. font.set_text(s, 0.0, flags=flags)

When we use the Matplotlib library to draw pictures, the following errors are easy to occur, and the drawn chart icons will appear garbled errors, Chinese cannot be displayed, etc., and the operation errors are as follows. What should I do at this time?
Insert picture description here
Insert picture description here
Next we write about the following solution:

plt.rcParams['font.sans-serif']=['SimHei'] #显示中文标签
plt.rcParams['axes.unicode_minus']=False   #解决负号“-”显示为方块的问题

The above two lines of code can solve the garbled characters, the Chinese cannot be displayed, and the minus sign shows the box. Let's take a look at the revised result: the
Insert picture description here
problem is easily solved, and comments are welcome to have a better way.

Guess you like

Origin blog.csdn.net/qq_44176343/article/details/109907061