我试着用zorder来移动圆环体前面的向量箭头,但不能很好的工作。矢量箭头总是出现在圆环体的后面,而不是它的中心。这是我正在使用的代码。
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
plt.rcParams.update({'font.size': 16})
n = 50
theta = np.linspace(0, 2.*np.pi, n)
phi = np.linspace(0, 2.*np.pi, n)
theta, phi = np.meshgrid(theta, phi)
c, a = 35, 6
x = (c + a*np.cos(theta)) * np.cos(phi)
y = (c + a*np.cos(theta)) * np.sin(phi)
z = a * np.sin(theta)
fig = plt.figure(figsize = (9, 6))
ax1 = fig.add_subplot(1, 2, 1, projection='3d')
ax1.set_xlim(-50, 50)
ax1.set_ylim(-50, 50)
ax1.set_zlim(-50, 50)
ax1.set_xlabel('\n\nCells [\u212B]')
ax1.set_ylabel('\n\nCells [\u212B]')
ax1.zaxis.set_rotate_label(False)
ax1.set_zlabel('Cells [\u212B]\n\n', rotation = 90)
ax1.plot_surface(x,y,z,rstride=1,cstride=5,color='w',edgecolor='c',
linewidth=.4, zorder = 0)
ax1.view_init(25, 55)
ax1.quiver(0, 0, 0, 0, 0, 60, color = 'm', zorder = 1)
ax1.text(-10, 5, 60, '\n$B_0$', color = 'm', fontsize = '20')
ax2 = fig.add_subplot(1, 2, 2, projection='3d')
ax2.set_xlim(-50, 50)
ax2.set_ylim(-50, 50)
ax2.set_zlim(-50, 50)
ax2.set_xlabel('\n\nCells [\u212B]')
ax2.set_zlabel('Cells [\u212B]\n\n')
ax2.plot_surface(x, y, z, rstride=1, cstride=5, color='w', edgecolor='c',
linewidth=.4, zorder = 0)
ax2.view_init(0, 90)
ax2.quiver(0, 0, 0, 0, 0, 40, color = 'm', zorder = 1)
ax2.text(-10, 5, 25, '$B_0$', color = 'm', fontsize = '20')
ax2.set_yticks([])
plt.savefig('TorusWithBField3D.png')
plt.show()
暂无答案!
目前还没有任何答案,快来回答吧!