属性错误:未知属性插值



我应该通过离散耦合微分方程来显示格雷-斯科特模型的图像。

当我添加imshow部分时,我开始收到此错误消息:

  File "C:UsersChad ThomasAnaconda3libsite-packagesmatplotlibartist.py", line 912, in _update_property
    raise AttributeError('Unknown property %s' % k)
AttributeError: Unknown property interpolations

我无法弄清楚问题是什么。错误来自底部的 imshow 代码,但我包含了其余部分,以防万一。

import numpy as np
import matplotlib.pyplot as plt
#parameters
N=128
F=.042
k=.062
Du=(2**-5)*(N**2/6.25)
Dv=adjust(1**-5)*(N**2/6.25)
tend=100                                      
dt=tend/N
t=0
#start arrays
U=np.ones((N,N))
V=np.zeros((N,N))
#Initial Value Boxes (20x20 in middle)
low=int(((N/2)-10))
high=int(((N/2)+10))+1
U[low:high,low:high]=.5
V[low:high,low:high]=.25
#Random Noise
U+=.01*np.random.random((N,N))
V+=.01*np.random.random((N,N))
#Solve
pstep=100
for t in range(tend):
    Usave=U.copy()
    M=U
    B=V
    U=-Du*(np.roll(U,1)+np.roll(U,-1)+np.roll(U,1,axis=False)+np.roll(U,-1,axis=False)-4*M)+(M*B*B)-F*(1-M)+(M+dt)
    Vsave=V.copy()
    V=-Dv*(np.roll(V,1)+np.roll(V,-1)+np.roll(V,1,axis=False)+np.roll(V,-1,axis=False)-4*B)-(M*B*B)+(F+k)*B+(B+dt)
    if t%pstep ==0:
        plt.imshow(U, interpolations='bicubic',cmap=plt.cm.jet)
        #plt.savefig("C:UsersChad ThomasDesktopPython Programsplotsimshow-"+str(t//pstep).zfill(3)+".png")

我只是想让它在这一点上显示某种图像。(希望中间有一个正方形(

这是一个

错字。 plt.imshow接受关键字参数interpolationinterpolations(请注意末尾缺少的s(。

https://matplotlib.org/api/_as_gen/matplotlib.pyplot.imshow.html

问题完全如前所述:没有属性插值。但是有一个属性interpolation,所以如果你把那行改成

plt.imshow(U, interpolation='bicubic',cmap=plt.cm.jet)

最新更新