从this post开始?
解决方法 该方法与 the other SO answer基本相同;将每行除以行的总和:df = df.divIDe(df.sum(axis=1),axis=0)
然后你可以照常调用df.plot(kind =’area’,stacked = True,…).
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltnp.random.seed(2015)y = np.random.randint(5,50,(10,3))x = np.arange(10)df = pd.DataFrame(y,index=x)df = df.divIDe(df.sum(axis=1),axis=0)ax = df.plot(kind='area',stacked=True,Title='100 % stacked area chart')ax.set_ylabel('Percent (%)')ax.margins(0,0) # Set margins to avoID "whitespace"plt.show()
产量
总结以上是内存溢出为你收集整理的python – pandas DataFrame的100%面积图全部内容,希望文章能够帮你解决python – pandas DataFrame的100%面积图所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)