Darcey BM
Darcey BM

Reputation: 301

How do you despine a facetgrid in Seaborn?

I have created the following plot in Seaborn using:

ax = sns.factorplot(x='metric', y='number', hue='drop', data=df, kind='bar')
plt.legend(loc='best')
plt.subplots_adjust(top=.925)
ax._legend.remove()
sns.despine(ax=ax)
plt.show()

enter image description here

However, this throws an error:

AttributeError: 'FacetGrid' object has no attribute 'spines'

I need to either turn the spines white or remove them, how can you do this for a factorplot/FacetGrid?

Upvotes: 2

Views: 894

Answers (1)

Thrastylon
Thrastylon

Reputation: 980

You can replace the following line

sns.despine(ax=ax)

with

ax.despine(left=True, bottom=True)

Note: The name ax is misleading, grid would be more indicative of what it is (a FacetGrid object).

Upvotes: 1

Related Questions