繁体   English   中英

matplotlib 从 x 轴而不是 y 轴绘制累积图

[英]matplotlib plot on cumulative graph from x-axis instead of y-axis

我使用以下代码生成了这个累积图表:

plt.hist(d.values(), normed=True, cumulative=True, label='CDF', histtype='step', alpha=0.8, color='r',
         orientation='horizontal')

在此处输入图片说明

但是我想要更像这样的东西,其中图形从 x 轴开始: 在此处输入图片说明

我该怎么做?

如果我正确理解你的第二个情节,你需要做的就是摆脱orientation='horizontal' and normed=True

这是一个例子

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import mlab


mu = 200
sigma = 25
n_bins = 50
x = mu + sigma*np.random.randn(10000)

n, bins, patches = plt.hist(x, n_bins,
                            histtype='step', cumulative=True)
plt.grid(True)
plt.title('cumulative step')
plt.show()

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM