绘制简单堆积面积图
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(6)
y1 = np.array([1,4,6,5,6,7])
y2 = np.array([4,5,4,8,7,6])
y3 = np.array([3,1,3,6,8,5])
# 绘制堆积面积图
plt.stackplot(x, y1, y2, y3)
plt.show()
对物流公司物流费用统计并且进行绘制堆积面积图
import numpy as np
import matplotlib.pyplot as plt
x = np.arange(1, 13)
y1 = np.array([198, 215, 245, 222, 200, 236, 201, 253, 236, 200, 266, 290])
y2 = np.array([203, 236, 200, 236, 269, 216, 298, 333, 301, 349, 360, 368])
y3 = np.array([185, 205, 226, 199, 238, 200, 250, 209, 246, 219, 253, 288])
plt.stackplot(x, y1, y2, y3)
plt.show()
运行如下: