Python draws line chart title with Chinese garbled characters

First explain the error phenomenon:
My drawing command is:

plt.title('类别' + class_name+'的各项分割精度指标')

The Chinese characters in the drawing results are not displayed
Insert image description here

Analyze the reasons

This is caused by not specifying Chinese fonts

solution:

Add the following to the header of the corresponding python file:

import matplotlib 
import matplotlib.pyplot as plt
matplotlib.rc("font",family='SimHei') # 中文字体

Insert image description here

Guess you like

Origin blog.csdn.net/ArcGis_Niu/article/details/134021179