假设我有一个名为 df 的 Pandas DataFrame 变量,其中包含 col1、col2、col3、col4 列。
使用 sns.catplot() 一切正常:
fig = sns.catplot(x='col1', y='col2', kind='bar', data=df, col='col3', hue='col4')
然而,我一写:
fig.axes[0].get_xlabel()
我收到以下错误:
AttributeError: 'numpy.ndarray' object has no attribute 'get_xlabel'
我知道我可以将 sns.barplot() 与 ax 参数一起使用,但我的目标是继续使用 sns.catplot() 并从 fig.axes[0] 获取 Axes 对象。