擅长:python、mysql、java
<p>只能使用<a href="http://matplotlib.org/api/figure_api.html#matplotlib.figure.Figure.add_axes" rel="noreferrer">add_axes</a>在Matplotlib中创建此类绘图。这是一个例子。</p>
<pre><code>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()
</code></pre>
<p><img src="https://i.stack.imgur.com/VeQz5.png" alt="Plot residuals in the bottom by adding another frame using <code>add_axes</code>"/></p>