[英]Rotate Y-axis categorical label in Seaborn plot?
大多數stackoverflow答案都建議使用ax.set_yticklabels(rotation = 90)
,盡管這樣做確實可行,但它還需要您提供位置參數labels
(如果不提供,則會提供TypeError
)。 我建議使用plt.yticks(rotation = 90)
。 它是這樣的:
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)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.