Python Matplotlib 绘制公司售卖数据线图:趋势线、图例、标题、标签、标识点
import matplotlib.pyplot as plt
# 数据
month_number = list(range(1, 13))
total_profit = [2500, 2630, 2140, 3400, 3600, 2760, 2980, 3700, 3540, 1990, 2340, 2900]
# 绘制图表
plt.plot(month_number, total_profit, linestyle='dashed', color='red', marker='o', markersize=8, linewidth=3)
# 标题和标签
plt.title('图一:全年公司售卖数据')
plt.xlabel('Month Number')
plt.ylabel('Sold units number')
# 图例
plt.legend(['Total Profit'])
# 显示图表
plt.show()
原文地址: https://www.cveoy.top/t/topic/bQdb 著作权归作者所有。请勿转载和采集!