Supposing I have a Pandas DataFrame variable called df which has columns col1, col2, col3, col4.
Using sns.catplot() everything works fine:
fig = sns.catplot(x='col1', y='col2', kind='bar', data=df, col='col3', hue='col4')
However, as soon as I write:
fig.axes[0].get_xlabel()
I get the following error:
AttributeError: 'numpy.ndarray' object has no attribute 'get_xlabel'
I know I can use sns.barplot() with ax parameter but my goal is to keep using sns.catplot() and get an Axes object from fig.axes[0].
If you check the help page, it writes:
So to get the xlabel like you did:
In this example, you have a facet plot that is 1 by 2, so the axes for the plots are stored in an (1,2) array:
And to access for example the one of the left (Smoker ="Yes"), you do:
To change the label: