如何更改 y 轴值以显示完整位数?
import seaborn as sns
sns.boxplot (x="waterfront", y="price", data=df)
我想要显示完整的数字范围(如屏幕截图“目标”中),但我创建的箱线图显示了带注释的数字(如屏幕截图“当前”中)。
目标:
当前:
从这里查看答案:Seaborn / Matplotlib:如何在因子图 y 轴中抑制科学记数法
这是您需要的代码:
import seaborn as sns
import matplotlib.pyplot as plt
sns.boxplot (x="waterfront", y="price", data=df)
plt.ticklabel_format(style='plain', axis='y',useOffset=False)
您需要复制此代码: 将seaborn导入为sns 将 matplotlib.pyplot 导入为 plt
自定义调色板 = ['#2477BF', '#F26101']
flierprops = dict(marker='D',markerfacecolor=['grey','#2477BF'],markersize=4,linestyle='none')
sns.boxplot(x='海滨', y='价格', 数据=df, 调色板=custom_palette, flierprops=flierprops)
plt.ticklabel_format(style='plain', axis='y', useOffset=True)
plt.show()