11,204
社区成员
发帖
与我相关
我的任务
分享
import matplotlib.pyplot as plt
import datetime
def draw_line(list_name,list_data,title1,label1):
figure = plt.figure()
plt.rcParams['font.sans-serif'] = ['SimHei'] # 显示中文标签
plt.rcParams['axes.unicode_minus'] = False # 这两行需要手动设置
ax1 = figure.add_subplot(1, 1, 1)
ax1.plot(list_name, list_data, '-o', label=label1)
ax1.legend()
# ax1.set_xticklabels(list_name, rotation=60)
ax1.set_title(title1 + '\n' + str(datetime.date.today()))
ax1.grid(True)
plt.show()
if __name__ == '__main__':
list_name1 = [1,2,3,4,5,6,7]
list_data1 = [1,2,3,4,5,6,7]
title1 = '标题'
label1 = '数据名称'
draw_line(list_name1,list_data1,title1,label1)
