我如何在 python (sympy) 值为 0 的所有点上画一条线?

How can i draw a line in all the points where i have 0 value with python (sympy)?

我想知道我的值为 0 的所有点。我希望它显示在我的绘图上。在所有值中划一条红线以使其明显。我不知道该怎么做,也找不到任何与此类似的 sympy 库。这是我的代码:

import inspect
from IPython.display import display, Math

from sympy import *
xi,eta,b,a = symbols("xi,eta,b,a")
Nq = Matrix([[1,xi,eta,xi**2,xi*eta,eta**2,xi**2*eta,xi*eta**2]])
AINV = Matrix([[1,1,1,1,-b,-a,-b,-a],
               [0,0,0,0,0,2*a,0,-2*a],
               [0,0,0,0,-2*b,0,2*b,0],
               [0,0,0,0,0,a,0,a],
               [1,-1,1,-1,0,0,0,0],
               [0,0,0,0,b,0,b,0],
               [-1,-1,1,1,2*b,0,-2*b,0],
               [-1,1,1,-1,0,-2*a,0,2*a]])
N = Nq*AINV
N1 = combsimp(N[0])
N2 = combsimp(N[1])
N3 = combsimp(N[2])
N4 = combsimp(N[3])
N5 = combsimp(N[4])
N6 = combsimp(N[5])
N7 = combsimp(N[6])
N8 = combsimp(N[7])

NN = Matrix([[N1,N2,N3,N4,N5,N6,N7,N8]])
NN


%matplotlib notebook


Xi = Matrix([0,12,16,8,4,2,4,7])
Yi = Matrix([4,0,12,7,3,5,7,8])

J1 = diff(NN,xi)*Xi
J2 = diff(NN,xi)*Yi
J3 = diff(NN,eta)*Xi
J4 = diff(NN,eta)*Yi

J = Matrix([[J1,J2],[J3,J4]])
JDet = J.det()
JDetPLOT = JDet.subs(a,1).subs(b,1)
plotting.plot3d(JDetPLOT,(xi,-1,1),(eta,-1,1))

您可以访问 matplotlib 轴,然后创建 3d 等高线图,如下所示:

p = plotting.plot3d(JDetPLOT,(xi,-1,1),(eta,-1,1))
xx, yy, zz = p[0].get_meshes()
p._backend.ax[0].contour(xx, yy, zz, colors="r", levels=[0])

请注意,我为轮廓设置了一条红线,但这(很可能)是您将要看到的。 Matplotlib 3D 并不是那么好:|