1

I have 2 dataframes. I make every df plot histogram looks like this:

df1
plt.show()

enter image description here

df2
plt.show()

enter image description here

if possible, I want to combine and show these histogram in single histogram but side by side with the different value. Is it possible?. my expected output looks like this Multiple Histogram (Example):

df_example
plt.show()

enter image description here

please give me advise.

Arief Hidayat
  • 937
  • 1
  • 8
  • 19

1 Answers1

2

I think you need something like this,

import matplotlib.pyplot as plt
import  pandas as pd
df1=pd.DataFrame({"a":[1,2,4,2,1,43,23,12,54,12,344,45,212,12,43]})
df2=pd.DataFrame({"b":[223,234,234,342,652,234,652,121,345,456,234,467,234,568,237]})
plt.hist([df1['a'],df2['b']], color = ['b','g'],label=['a','b'])
plt.legend()
plt.show()

enter image description here

Mohamed Thasin ah
  • 10,754
  • 11
  • 52
  • 111