Python 具有多索引列的子地块

Python 具有多索引列的子地块,python,pandas,Python,Pandas,根据以下答案,我应该能够使用多索引子图来显示成对图: 但这似乎对我不起作用。 这是一个例子: import pandas as pd import numpy as np # prepare example data adf = pd.DataFrame(index = pd.date_range('2019-01-01', periods=30), data= np.random.randint(0,100,(30,2)), columns=['X','Y']) b

根据以下答案,我应该能够使用多索引子图来显示成对图:

但这似乎对我不起作用。 这是一个例子:

import pandas as pd
import numpy as np
# prepare example data
adf = pd.DataFrame(index = pd.date_range('2019-01-01', periods=30), 
             data= np.random.randint(0,100,(30,2)), columns=['X','Y'])
bdf = pd.DataFrame(index = pd.date_range('2019-01-01', periods=30), 
             data= np.random.randint(0,100,(30,2)), columns=['X','Y'])
df = pd.concat({'a': adf, 'b': bdf}).unstack(level=0)

# plot
_ = df.plot(kind='line', subplots=True, figsize=(10, 10))
结果是每列有4个图

但我想要两个像这样的两两图:

我可以通过以下方式实现这一点:

_ = [df.loc[:,df.columns.get_level_values(0) == c].plot() for c in df.columns.get_level_values(0).unique()]
但是,如果使用多索引和子批次功能,这不可能吗