Scipy box cox曲线函数不显示p

2024-09-24 00:27:33 发布

您现在位置:Python中文网/ 问答频道 /正文

我运行这个代码。在

fig = plt.figure(figsize=(12,15))
ax1 = fig.add_subplot(211)

prob = sp.stats.probplot(var, dist=sp.stats.norm, plot=ax1)
ax1.set_xlabel('')
ax1.set_title('Probplot against normal distribution')

它工作得很好,我把它作为输出。在

enter image description here

但是,当我尝试运行box_cox_normality图时,它不会生成任何图形

^{pr2}$

我明白了。在

enter image description here

我不知道它为什么不策划。我在内联使用ipythonmatplotlib,所以不需要这样做表演()

请告知

编辑:

我不确定问题是否出在数据上。问题是除非我这么做 plt.绘图(arg)显式地它没有打印。在

这里有一个例子。请注意,这个变量中没有遗漏的值,因为它已经被处理过了。在

代码如下:

fig = plt.figure(figsize=(15,8))
ax = fig.add_subplot(111)
lamdas,ppc=sp.stats.boxcox_normplot(var, -20, 20, plot=ax)
#plt.plot(lamdas,ppc)
max_ppc=lamdas[ppc.argsort()[::-1][0]]
ax.axvline(lamdas[ppc.argsort()[::-1][0]],color='b')
y, lmax_mle = sp.stats.boxcox(var)
lmax_pearsonr = sp.stats.boxcox_normmax(var)
ax.axvline(lmax_mle, color='r')
ax.axvline(lmax_pearsonr, color='g', ls='--')
print max_ppc,lmax_mle,lmax_pearsonr

boxcox范数图应该独立工作,因为它接受plot=ax参数。但它给出了下面的图,显然没有打印出boxcox图。检查一下plt.绘图()被注释掉。在

enter image description here

现在我用plt.绘图()语句未注释。在

enter image description here

如你所见,它描绘了完整的情节。所以某个地方出了点问题,现在需要明确指出plt图要绘制的语句。BoxCox正在做正确的转变。早些时候我没看到这样的问题


Tags: 绘图plotvarstatsfigpltaxsp