使用Python实现累积面积图 using Python for cumulative area plot

Code

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(444)

data = np.random.rand(5, 10).cumsum(axis=1)
years = range(2010, 2020)
bottom = np.zeros(len(data[0]))
for i in range(len(data)):
    plt.fill_between(x=years, y1=bottom, y2=bottom+data[i])
    bottom += data[i]
plt.savefig('cumulative_area_plot.png')
plt.show()

Ouput

使用Python实现累积面积图 using Python for cumulative area plot_第1张图片

 

你可能感兴趣的:(绘图,python,开发语言)