Python折线图详细绘制讲解

import matplotlib.pyplot as plt

# 中文乱码和坐标轴负号处理。
plt.rc('font', family='SimHei', weight='bold')

plt.rcParams['axes.unicode_minus'] = False


y = [71, 94.1, 47.1, 72.4, 86.1, 79, 71, 73.3, 55, 39.1]

x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

plt.figure(figsize=(7,4)) #画布大小

plt.plot(x, y, 'b', lw = 1.5) # 蓝色的线

plt.plot(x, y, 'ro') #离散的点

plt.grid(True)

plt.axis('tight')

plt.xlabel('排名')

plt.ylabel('价格')

plt.title('前10名价格走势')

plt.show()

猜你喜欢

转载自blog.csdn.net/weixin_48117689/article/details/123957320