Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何在matplotlib绘图的底部显示残差_Python_Matplotlib_Plot - Fatal编程技术网

Python 如何在matplotlib绘图的底部显示残差

Python 如何在matplotlib绘图的底部显示残差,python,matplotlib,plot,Python,Matplotlib,Plot,我想复制这个情节。错误显示在绘图的底部。你能分享一下它是怎么做的吗? 这里有一个关于stackoverflow的例子,但它在R中。 我想您正在寻找这样的错误条 您可以添加额外的子图,并使用错误条绘制点 编辑:绘图之间无边框: from pylab import * subplots_adjust(hspace=0.,wspace=0.) subplot(211) imshow(rand(100,100), cmap=cm.BuPu_r) subplot(212) imshow(rand(100

我想复制这个情节。错误显示在绘图的底部。你能分享一下它是怎么做的吗?

这里有一个关于stackoverflow的例子,但它在R中。

我想您正在寻找这样的错误条

您可以添加额外的子图,并使用错误条绘制点

编辑:绘图之间无边框:

from pylab import *
subplots_adjust(hspace=0.,wspace=0.)
subplot(211)
imshow(rand(100,100), cmap=cm.BuPu_r)
subplot(212)
imshow(rand(100,100), cmap=cm.BuPu_r)
show()

只能使用在Matplotlib中创建此类绘图。这里有一个例子

from scipy.optimize import curve_fit
#Data
x = arange(1,10,0.2)
ynoise = x*numpy.random.rand(len(x)) 
#Noise; noise is scaled by x, in order to it be noticable on a x-squared function
ydata = x**2 + ynoise #Noisy data

#Model
Fofx = lambda x,a,b,c: a*x**2+b*x+c
#Best fit parameters
p, cov = curve_fit(Fofx,x,ydata)

#PLOT
fig1 = figure(1)
#Plot Data-model
frame1=fig1.add_axes((.1,.3,.8,.6))
#xstart, ystart, xend, yend [units are fraction of the image frame, from bottom left corner]
plot(x,ydata,'.b') #Noisy data
plot(x,Fofx(x,*p),'-r') #Best fit model
frame1.set_xticklabels([]) #Remove x-tic labels for the first frame
grid()

#Residual plot
difference = Fofx(x,*p) - ydata
frame2=fig1.add_axes((.1,.1,.8,.2))        
plot(x,difference,'or')
grid()

添加轴“>

您的链接没有显示如何将绘图连接在一起。我认为错误条是问题所在。我从来没有这样做过,但在谷歌快速搜索之后,我会尝试这样做:我用示例代码更新了我的答案,以消除此线程提供的解决方案的子批次之间的差距。不起作用,出现错误。Figure not defined如果“Figure not defined”是错误,那么我猜您必须从pylab包导入它,就像从pylab导入一样*