如何在我使用Python(Sympy)具有0个值的所有点上绘制一条线?

发布于 2025-02-04 03:19:40 字数 1121 浏览 3 评论 0原文

我想知道我的价值为0的所有点。我希望它在我的情节上显示。在所有值中都有一个红线,以使其显然。我不知道该怎么做,也找不到与此类似的Syspy Libiraries。这是我的代码:

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))

I want to know all the points where i have the value of 0. And i would like it to show on my plot. Have a redline in all the values to make it obviously. I have no idea on how to do it and i could not find any sympy libiraries that did something similarly to this. This is my code:

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))

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

俏︾媚 2025-02-11 03:19:40

您可以访问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并不是那么好:|

You can access the matplotlib axes and later create a 3d contour plot, like this:

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])

Note that I set a red line for contour, however this is (most likely) what you are going to see. Matplotlib 3D isn't really that great :|

enter image description here

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文