我正在尝试使用 matplotlib 从与Z轴相切的圆中获取圆弧,如下图所示。
我只想要一个被黄色矩形覆盖的弧线。下面是获取圆圈的代码。
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
r = input('Enter the radius: ')
d = 2*r
theta = np.linspace(0, 2 * np.pi, 201)
y = d*np.cos(theta)
z = d*np.sin(theta)
for i in range(1):
phi = i*np.pi
ax.plot(y*np.sin(phi)+d*np.sin(phi),
y*np.cos(phi)+d*np.cos(phi), z)
ax.plot((0,0),(0,0), (-d,d), '-r', label='z-axis')
ax.set_xlabel('X-Axis')
ax.set_ylabel('Y-Axis')
ax.set_zlabel('Z-Axis')
ax.legend()
plt.show()
如果您能提供以下信息,我将不胜感激,
- 我怎样才能得到弧线?
- 如何在XY平面上更改与Z轴相切的圆弧角度?