Andy
Andy

Reputation: 1092

matplotlib bar plot adjust bar direction

I want to start the bars from the bottom. How can I change the starting point from zero to e.g. -2 ?

My code:

import matplotlib.pyplot as plt
import numpy as np


N=1000
sample=np.random.random_integers(1,10,N)
hist,bins=np.histogram(sample)

plt.bar(bins[:-1],np.log10(1.*hist/N),np.diff(bins))

plt.show()

Output: enter image description here

Upvotes: 0

Views: 716

Answers (1)

hardythe1
hardythe1

Reputation: 104

Try This:

plt.bar(bins[:-1],abs(np.log10(1.*hist/N)),np.diff(bins))

Upvotes: 1

Related Questions