I have large data that I want to put into bins and display on a histogram. Yet, before I display the histogram, I want to make some arrangements on the data. The code is as follows:
import numpy as np
import matplotlib.pyplot as plt
data_set=np.random.randint(1000, size=1000)
c = 5
a, b = np.histogram(data_set, bins=20)
a = [i * c for i in a]
fig, ax = plt.subplots(figsize=(8, 5))
ax.hist(a, bins=b, alpha=0.8)
plt.show()
I can manage plotting using plt.hist(data_set, bins=20)
, but I can't do it after I play with the histogram data. In this case, I multiplied all the entries by 5, but the manipulation can be more complicated.
How do I plot a histogram using np.histogram()
output?