0

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

1
  • Sorry, removed the commentary because I realized of another thing. I think you'll find that it did change, but just slightly. Commented May 27, 2015 at 11:39

1 Answer 1

1

Try This:

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

Sign up to request clarification or add additional context in comments.

3 Comments

I want to keep the y-axis labels as they are, because it's the logarithm
Hardythe1 is on the right track. Now just add bottom=-2 within the plt.bar()
thx! this worked now: plt.bar(bins[:-1],2-abs(np.log10(1.*hist/N)),np.diff(bins),bottom=-2)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.