在subplot中有时无法使用surf函数

每当我想要在subplot中使用surf函数生成3d图像时,我会声明projection=“3d”。
但是有的时候代码无法运行,并且我会遇到这样的提示
PyError ($(Expr(:escape, :(ccall(#= C:\Users\lenovo.julia\packages\PyCall\zqDXB\src\pyfncall.jl:43 =# @pysym(:PyObject_Call), PyPtr, (PyPtr, PyPtr, PyPtr), o, pyargsptr, kw))))) <class ‘ValueError’>
ValueError(“Unknown projection ‘3d’”)
File “C:\Users\lenovo.julia\conda\3\lib\site-packages\matplotlib\pyplot.py”, line 1076, in subplot
a = fig.add_subplot(*args, **kwargs)
File “C:\Users\lenovo.julia\conda\3\lib\site-packages\matplotlib\figure.py”, line 1396, in add_subplot
self._process_projection_requirements(*args, **kwargs)
File “C:\Users\lenovo.julia\conda\3\lib\site-packages\matplotlib\figure.py”, line 1120, in process_projection_requirements
projection_class = projections.get_projection_class(projection)
File "C:\Users\lenovo.julia\conda\3\lib\site-packages\matplotlib\projections_init
.py", line 60, in get_projection_class
raise ValueError(“Unknown projection %r” % projection)

下面是对应的代码,内容是关于一个二维Poisson方程的求解,结合Gauss-Legendre quadrature rule for triangles的积分逼近以计算FEM的。

using LinearAlgebra, PyPlot
f(x,y)=(pi^2*x*(1-x)+2)*sin(pi*y)+(pi^2*y*(1-y)+2)*sin(pi*x)
u_e(x,y)=x*(1-x)*sin(pi*y)+y*(1-y)*sin(pi*x)

xf=[0.659027622374092 
    0.659027622374092  
    0.231933368553031 
    0.231933368553031
    0.109039009072877
    0.109039009072877]
yf=[0.231933368553031
    0.109039009072877
    0.659027622374092
    0.109039009072877
    0.659027622374092
    0.231933368553031]
w=0.16666666666666666667

function delta_N(n)
    m=2^n
    A=zeros(m^2,m^2)
    h=1/(m+1)
    for i in 1:m
        for j in 1:m
            k=(i-1)*m+j
            A[k,k]=6
            if i>1 A[k,(i-2)*m+j]=-1 end
            if i>1&&j<m A[k,(i-2)*m+j+1]=-1 end
            if j<m A[k,(i-1)*m+j+1]=-1 end
            if i<m A[k,i*m+j]=-1 end
            if j>1 A[k,(i-1)*m+j-1]=-1 end
            if i<m&&j>1 A[k,i*m+j-1]=-1 end
        end
    end

    ft=zeros(m^2)
    for i in 1:m
        for j in 1:m
            k=(i-1)*m+j
            for r in 1:6 
                ft[k]=ft[k]+f(i*h+xf[r]*h,j*h+yf[r]*h)*(1-xf[r]-yf[r])
                ft[k]=ft[k]+f(i*h-xf[r]*h,j*h+h-yf[r]*h)*yf[r]
                ft[k]=ft[k]+f(i*h-h+xf[r]*h,j*h+yf[r]*h)*xf[r]
                ft[k]=ft[k]+f(i*h-xf[r]*h,j*h-yf[r]*h)*(1-xf[r]-yf[r])
                ft[k]=ft[k]+f(i*h+xf[r]*h,j*h-h+yf[r]*h)*yf[r]
                ft[k]=ft[k]+f(i*h+h-xf[r]*h,j*h-yf[r]*h)*xf[r] 
            end
        end
    end
    ft=h^2*w*ft

    u=inv(A)*ft

    z=zeros(m+2,m+2)
    for i in 0:m-1
        for j in 1:m
            z[i+2,j+1]=u[i*m+j]
        end
    end

    xspan=0:h:1
    yspan=0:h:1

    subplot(2,3,n-1,projection="3d")
    surf(xspan,yspan,z)
    title("m=$m");
end

fig = PyPlot.figure(figsize=(12,10))
for n in 2:6
    delta_N(n)
end
tight_layout();

希望有人能够帮助我解决这个问题,十分感谢。

京ICP备17009874号-2