我想使用matplotlib的条形图功能绘制以下形式的数据:
data = {'Room A':
{'Shelf 1':
{'Milk': 10,
'Water': 20},
'Shelf 2':
{'Sugar': 5,
'Honey': 6}
},
'Room B':
{'Shelf 1':
{'Wheat': 4,
'Corn': 7},
'Shelf 2':
{'Chicken': 2,
'Cow': 1}
}
}
Run Code Online (Sandbox Code Playgroud)
条形图应该看起来像这样.应从x轴上的标签可见条形图组.有没有办法用matplotlib做到这一点?
以下代码仅显示主要类别['one','two','three','four','five','six']作为x轴标签.有没有办法显示子类别['A','B','C','D']作为辅助x轴标签?

df = pd.DataFrame(np.random.rand(6, 4),
index=['one', 'two', 'three', 'four', 'five', 'six'],
columns=pd.Index(['A', 'B', 'C', 'D'],
name='Genus')).round(2)
df.plot(kind='bar',figsize=(10,4))
Run Code Online (Sandbox Code Playgroud)