Python 是否有使用matplotlib自动生成累积面积图的功能?
下面使用matplotlib库的代码为我们提供了一个简单的面积图Python 是否有使用matplotlib自动生成累积面积图的功能?,python,matplotlib,area,Python,Matplotlib,Area,下面使用matplotlib库的代码为我们提供了一个简单的面积图 import matplotlib.pyplot as plt x = range(1,6) y = [1,2,3,4,3] plt.plot(x,y, labels=['A']) 是否有一个函数可以生成累积面积图,而无需将y转换为: y_cumulative = [1,3,6,10,13] 谢谢。您可以使用或编写自己的普通python函数 def cumsum(seq): """r
import matplotlib.pyplot as plt
x = range(1,6)
y = [1,2,3,4,3]
plt.plot(x,y, labels=['A'])
是否有一个函数可以生成累积面积图,而无需将y转换为:
y_cumulative = [1,3,6,10,13]
谢谢。您可以使用或编写自己的普通python函数
def cumsum(seq):
"""returns a list with the cumulative sum of seq
"""
result = []
current = 0
for elt in seq:
current += elt
result.append(current)
return result
不,打电话给numpy.cumsum