I have a pandas dataframe like the following:
df = pd.DataFrame({ 'a_wood' : np.random.randn(100),
'a_grassland' : np.random.randn(100),
'a_settlement' : np.random.randn(100),
'b_wood' : np.random.randn(100),
'b_grassland' : np.random.randn(100),
'b_settlement' : np.random.randn(100)})
and I want to create histograms of this data with every dataframe header in one subplot.
fig, ax = plt.subplots(2, 3, sharex='col', sharey='row')
m=0
for i in range(2):
for j in range(3):
df.hist(column = df.columns[m], bins = 12, ax=ax[i,j], figsize=(20, 18))
m+=1
For that the previous code works perfectly but now I want to combine eyery a and b header (e.g. "a_woods" and "b-woods") to one subplot so there would be just three histograms. I tried assigning two columns to df.columns[[m,m+3]]
but this doesn't work. I also have an index column with strings like "day_1", which I want to be on the x-axis. Can someone help me?