gpt4 book ai didi

python - 使用 seaborn distplot 设置轴最大值

转载 作者:行者123 更新时间:2023-12-03 14:56:06 24 4
gpt4 key购买 nike

是否可以为 seaborn distplots 设置最小和最大显示限制?

我正在尝试遍历 Pandas 数据框的列,但我所有的输出都获得相同的轴。

for v in var_list: 
df[v].dropna(inplace=True)
var=df[v].max()
vstar = v + "_output.png"
splot = sns.distplot(df[v])
# sns.plt.xlim(0, var)
splot.figure.savefig(vstar)
splot.autoscale()

我已经用 sns.plt.xlim() 和 autoscale() 做了一些尝试,但似乎都没有成功。我错过了什么?

最佳答案

您应该可以通过使用 plt.xlim(0, var) 获得您想要的东西。直接地:

In [24]: np.random.seed(0)

In [25]: data = np.random.randn(1000)

In [26]: sns.distplot(data)
Out[26]: <matplotlib.axes._subplots.AxesSubplot at 0xfa291967f0>

In [27]: plt.savefig('plot1.png')

enter image description here
In [39]: plt.clf()

In [40]: sns.distplot(data)
Out[40]: <matplotlib.axes._subplots.AxesSubplot at 0xfa291bcd30>

In [41]: plt.xlim(-10, 10)
Out[41]: (-10, 10)

In [42]: plt.savefig('plot2.png')

enter image description here

关于python - 使用 seaborn distplot 设置轴最大值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52135315/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com