简体   繁体   中英

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

I generated this cumulative chart using this code:

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

在此处输入图片说明

However i want something more like this where the graph starts from the x-axis: 在此处输入图片说明

How do i go about doing that?

If I understand your second plot correctly, all you need to do is to get rid of orientation='horizontal' and normed=True

Here is an example

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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