1

I'm trying to create a histogram with two data sets overlying each other, however whenever I plot it using pandas.DataFrame.hist(), it creates two graphs:

The code is simply:

ratios.hist(bins = 100)
plt.show()

where ratios is just a DataFrame, 2 columns by about 7000 rows. Any idea on how to put the two graphs on the same axis?

1 Answer 1

3

Try plot.hist instead:

ratios = pd.DataFrame(np.random.normal((1, 2), size=(100, 2)))
ratios.hist(bins=10)

This generates:

enter image description here

ratios.plot.hist(alpha=0.5, bins=10)

This, on the other hand, puts them on the same graph:

enter image description here

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

Comments

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.