Zenvega
Zenvega

Reputation: 2054

In seaborn, how to turn off xaxis title, but keep xaxis labels and ticks?

I am trying to hide x axis title, but keep x axis ticks and tick labels. The only option that I have gotten to work is ax.set_xlabel(''). Is there an option to set x axis title's visibility alone to false? Thank you.

Upvotes: 1

Views: 485

Answers (1)

Alex
Alex

Reputation: 7075

For a single ax returned from a seaborn plotting function we can use ax.xaxis.label.set_visible(False):

import seaborn as sns

df = sns.load_dataset("tips")
ax = sns.barplot(x="day", y="total_bill", data=df)
ax.xaxis.label.set_visible(False)

Barplot with xaxis label removed

Upvotes: 2

Related Questions