简体   繁体   English

迫使两个 matplotlib 3d 地块在一个图中

[英]forcing two matplotlib 3d plots to be in one figure

How can I make these to be overlapping or be together in one figure (not side by side):我怎样才能使这些重叠或一起出现在一个图中(而不是并排):

fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlim(-6, 6)
ax.set_ylim(-6, 6)
ax.set_zlim(-6, 6)
xx_floor, yy_floor, zz_floor = plot_plane(plane1['a'],
                                          plane1['b'],
                                          plane1['c'],
                                          plane1['d'],
                                          xwin=[-2, 2],
                                          ywin=[-2, 2])

ax.plot_surface(xx_floor, yy_floor, zz_floor, color=(0, 1, 1, 0.3))


plane2_points = plane2[:3]
p0, p1, p2 = plane2_points
x0, y0, z0 = p0
x1, y1, z1 = p1
x2, y2, z2 = p2
ux, uy, uz = u = [x1 - x0, y1 - y0, z1 - z0]
vx, vy, vz = v = [x2 - x0, y2 - y0, z2 - z0]
u_cross_v = [uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx]
plane2_point = np.array(p0)
plane2_normal = np.array(u_cross_v)
pointdot = -plane2_point.dot(plane2_normal)
xx, yy = np.meshgrid(range(6), range(6))
z = (-plane2_normal[0] * xx - plane2_normal[1] * yy - pointdot) * 1. / plane2_normal[2]
plt3d = plt.figure().gca(projection='3d')
plt3d.plot_surface(xx, yy, z)
plt.show()
plt.close(fig=fig)

Currently, I see two figures that I should close the first one to see the second one.目前,我看到两个数字,我应该关闭第一个才能看到第二个。

在此处输入图像描述

fig = plt.figure()
ax = Axes3D(fig)
ax.set_xlim(-6, 6)
ax.set_ylim(-6, 6)
ax.set_zlim(-6, 6)
xx_floor, yy_floor, zz_floor = plot_plane(plane1['a'],
                                          plane1['b'],
                                          plane1['c'],
                                          plane1['d'],
                                          xwin=[-2, 2],
                                          ywin=[-2, 2])

ax.plot_surface(xx_floor, yy_floor, zz_floor, color=(0, 1, 1, 0.3))


plane2_points = plane2[:3]
p0, p1, p2 = plane2_points
x0, y0, z0 = p0
x1, y1, z1 = p1
x2, y2, z2 = p2
ux, uy, uz = u = [x1 - x0, y1 - y0, z1 - z0]
vx, vy, vz = v = [x2 - x0, y2 - y0, z2 - z0]
u_cross_v = [uy * vz - uz * vy, uz * vx - ux * vz, ux * vy - uy * vx]
plane2_point = np.array(p0)
plane2_normal = np.array(u_cross_v)
pointdot = -plane2_point.dot(plane2_normal)
xx, yy = np.meshgrid(range(6), range(6))
z = (-plane2_normal[0] * xx - plane2_normal[1] * yy - pointdot) * 1. / plane2_normal[2]
#plt3d = plt.figure().gca(projection='3d')
#plt3d.plot_surface(xx, yy, z)
ax.plot_surface(xx, yy, z)
plt.show()
plt.close(fig=fig)

Followed the instructions by swatchai遵循swatchai的指示

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM