Reputation: 5331
To borrow some default code with default libraries (extra helpful that you have to load the data explicitly, instead of having it polluting globals like in R...):
sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(y="day", x="total_bill", data=tips)
This produces the following image:
I want to rotate the day of the week labels 90 degrees such that the baseline for those labels matches the word day
, also on the Y axis.
I've looked at the answers already here, but they seem primarily to deal with (1) the X axis and (2) the first-order Y-axis label (here, the day
label) rather than the Y-axis sub-labels (here, the days of the week).
Upvotes: 0
Views: 903
Reputation: 459
Most stackoverflow answers would recommend using ax.set_yticklabels(rotation = 90)
, while this does work, it also requires you to provide the positional parameter labels
(failing to provide this will give you a TypeError
). I'd recommend using plt.yticks(rotation = 90)
. This is how it'd look:
import seaborn as sns
import matplotlib.pyplot as plt
sns.set(style="whitegrid")
tips = sns.load_dataset("tips")
ax = sns.violinplot(y="day", x="total_bill", data=tips)
plt.yticks(rotation = 90)
plt.show(ax)
Upvotes: 1