【发布时间】:2021-12-29 16:00:37
【问题描述】:
我有问题。我有一个数据框df。我想在 seaborn 的帮助下绘制散点图。但我想改变 x 轴。我希望 x 轴从 4.0 到 5.0 更精细。距离应该更小,例如4.1、4.2 甚至更好。
如何设置让 x 轴显示更精细,以便更好地查看 4.0 的值?
我看了seaborn, pylab - changing xticks from float to int,How to change the X axis range in seaborn in python?
d = {'review_scores_accuracy': [1.1, 2.0, 4.5, 5.0, 4.9, 4.8, 4.7],
'review_scores_rating': [1.1, 2.0, 4.6, 3.9, 4.2, 4.5, 4.2]}
df = pd.DataFrame(data=d)
fig, ax = plt.subplots(figsize=(20,10))
sns.scatterplot(data=df, x="review_scores_rating", y="review_scores_accuracy", ax = ax )
# ax.set_xlim(1,5)
# ax.set_xticks(1,2,3,4,4.1,4.2)
plt.show()
【问题讨论】:
标签: python pandas matplotlib seaborn