中文不显示:
链接:https://pan.baidu.com/s/1BD7zQEBUfcIs6mC2CPYy6A?pwd=v120
提取码:v120
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# 设置中文显示,需要填上字体SimHei.ttf所在的位置
my_font = FontProperties(fname='/opt/software/computer_vision/codes/My_codes/obeject_detection/tongjizhihaoxiong/data/SimHei.ttf')
# 数据集名称和对应的y值
datasets = ['awa2', 'cub', 'flo', 'sun']
y_values = [85, 1024, 1024, 89]
# 创建柱状图,设置颜色为绿色
plt.bar(datasets, y_values, color='green')
# 设置图表标题和轴标签
plt.title('柱状图示例',fontproperties=my_font)
plt.xlabel('数据集名称',fontproperties=my_font)
plt.ylabel('维度',fontproperties=my_font)
# 显示图表
plt.show()