matplotlib(一)
绘制简单的折线:
代码如下:
# coding: utf-8
import matplotlib.pyplot as plt
import numpy as np
# pre-datas
y1 = [0,1,2,3,4,18,6,7,8,9]
y2 = [30,12,12,67,14,15,45,17,18,19]
x = np.arange(1, 11, 1) # x坐标
print(x)
plt.plot(x, y1, lw=1, c='red', marker='s', ms=4, label='Y轴1') # 绘制y1
plt.plot(x, y2, lw=1, c='g', marker='o', label='Y轴2') # 绘制y2
# plt-style
plt.xticks(x) # x轴的刻度
plt.xlim(0.5, 10.5) # x轴坐标范围
plt.ylim(0, 100) # y轴坐标范围
plt.xlabel('X-Name') # x轴标注
plt.ylabel('Y-Name') # y轴标注
plt.legend() # 图例
plt.savefig("D:\est.png") # 保存图片
plt.show()
plt.plot(x, y1, lw=1, c='red', marker='s', ms=4, label='Y1')
: c代表color,marker代表节点形状,ms代表marker size,label是折现名称
形状列表: