import matplotlib.pyplot as plt

x = np.array([1,2,3,4,5])
y = np.array([2,4,6,8,10])
z = np.array([3,6,9,12,15])
x.tolist()
print(x)

figure, axes = plt.subplots(nrows=1, ncols=2, figsize=(12,8), dpi=80 )
axes[0].plot(x, y, color='r', linestyle='--', label = 'ShangHai')
axes[1].plot(x, z, color='g', linestyle='-.', label = 'BeiJing')

#显示图例
axes[0].legend() #默认loc=Best
axes[1].legend()

#添加网格信息
axes[0].grid(True, linestyle='--', alpha=0.5) #默认是True,风格设置为虚线,alpha为透明度
axes[1].grid(True, linestyle='--', alpha=0.5)

#添加标题
axes[0].set_xlabel('Time')
axes[0].set_ylabel('Temperature')
axes[0].set_title("Curve of ShangHai's Temperature Change with Time")
axes[1].set_xlabel('Time')
axes[1].set_ylabel('Temperature')
axes[1].set_title("Curve of BeiJing's Temperature Change with Time")

plt.savefig('./test1.png')
plt.show()
plt.plot(x, y, marker='+', color='coral')

image
image

reference

https://blog.csdn.net/hesongz...


anie
4 声望0 粉丝

引用和评论

0 条评论