Reputation: 69
i have this table:
Wow Bob Class Cook shlook ban
1 2.5 0 0 d 44.0
3 7.5 0 1 f 55.0
5 12.5 0 0 g 56.0
4 10.0 0 1 c 3.0
6 15.0 0 0 esd 323.0
.. ... ... ... ... ... ...
2 14.0 2 1 f NaN
2 15.0 2 1 d 2.0
2 16.0 2 0 d 2.0
2 17.0 2 0 f 2.0
2 18.0 2 1 g NaN
and I've been trying to plot a seaborn.pairblot and to dotate the ylables (not ticks) 90 degrees using this code:
for axes in g.axes.flat:
axes.set_ylabel(axes.get_ylabel(), rotation=90, horizontalalignment='left')
plt.show()
As you can see, the labels are not rotated. What should i do?
Thank you!
Upvotes: 1
Views: 1704
Reputation: 46968
Set the rotation to be 0 and ha to "right":
sns.set()
tips = sns.load_dataset("tips")
#fig, ax = plt.subplots(1, 2,figsize=(10,4))
g = sns.pairplot(tips)
for axes in g.axes.flat:
axes.set_ylabel(axes.get_ylabel(), rotation=0, horizontalalignment='right')
plt.show()
A useful place to check is the matplotlib vignette, :
You can lay out text with the alignment arguments horizontalalignment, verticalalignment, and multialignment. horizontalalignment controls whether the x positional argument for the text indicates the left, center or right side of the text bounding box.
Upvotes: 2