3

You can see there is histogram below.
It is made like pl.hist(data1,bins=20,color='green',histtype="step",cumulative=-1)
How to scale the histogram?
For example, let the height of the histogram be one third of it is like now.

Besides, it is a way to remove the vertical line at the left?

enter image description here

questionhang
  • 735
  • 2
  • 12
  • 31

1 Answers1

7

The matplotlib hist is actually just making calls to some other functions. It is often easier to use these directly allowing you to inspect the data and modify it directly:

# Generate some data
data = np.random.normal(size=1000)

# Generate the histogram data directly
hist, bin_edges = np.histogram(data, bins=10)

# Get the reversed cumulative sum
hist_neg_cumulative = [np.sum(hist[i:]) for i in range(len(hist))]

# Get the cin centres rather than the edges
bin_centers = (bin_edges[:-1] + bin_edges[1:]) / 2.

# Plot
plt.step(bin_centers, hist_neg_cumulative)

plt.show()

The hist_neg_cumulative is the array of data being plotted. So you can rescale is as you wish before passing it to the plotting function. This also doesn't plot the vertical line.

Greg
  • 11,654
  • 3
  • 44
  • 50