How to plot a helix around the orange curve given by list? Azimuth, elevation and figsize are set for the desired result.
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
from numpy import sin, cos
A = [-0.1646169553829357, -0.18045534297929358, -0.19607272004818602, -0.211354488132617, -0.22616904489940454, -0.24036624624003963, -0.25377639986609546, -0.26621030641288784, -0.27746107555189253, -0.287309176814374, -0.2955313683720342, -0.3019143406048014, -0.3062726740423563]
B = [0.13385167110565344, 0.13161004556697875, 0.12815132761818687, 0.1234273074581178, 0.11739746666382476, 0.11003213593352616, 0.10131707253912245, 0.09125949610772532, 0.07989522181968708, 0.06729724452652447, 0.053583847907859236, 0.038924841462667246, 0.023542804704085943]
# Plot figure with size
figsize=(10,5)
fig = plt.figure(figsize=figsize)
# Axes
ax = fig.gca(projection = '3d')
azimuth=90
elevation=90
ax.azim = azimuth # y rotation (default=270)
ax.elev = elevation # x rotation (default=0)
r = 0.1
c = 0.5
t = np.linspace(0, 5000, 100)
# parametric equation of a helix
x = r*cos(t)
y = r*sin(t)
z = c*t
ax.plot(x, y, z, zdir='z', lw=2)
ax.plot(A, B)
plt.show()
The desired result is the orange curve that goes through the centres of the helix.
Could you please elaborate more or add more details in the curve ?
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np
fig = plt.figure()
ax = fig.gca(projection='3d')
u=np.linspace(0,4*np.pi,50);
v=np.linspace(0,2*np.pi,50);
u,v=np.meshgrid(u, v) ;
x=(1.2+0.5*np.cos(v))*np.cos(u);
y=(1.2+0.5*np.cos(v))*np.sin(u);
z=0.5*np.sin(v)+u/np.pi;
# Plot the surface.
surf = ax.plot_surface(x,y,z, cmap=cm.jet,
linewidth=0, antialiased=False)
#plot the 3d line
u = np.linspace(0,4*np.pi,40)
x=1.2*np.cos(u);
y=1.2*np.sin(u);
z=u/np.pi;
ax.plot(x,y,z,'b');
fig = plt.figure()
ax = fig.gca(projection='3d')
u=np.linspace(0,4*np.pi,50);
v=np.linspace(0,2*np.pi,50);
u,v=np.meshgrid(u, v) ;
x=(1.2+0.5*np.cos(v))*np.cos(u);
y=(1.2+0.5*np.cos(v))*np.sin(u);
z=0.5*np.sin(v)+u/np.pi;
# Plot a basic wireframe.
ax.plot_wireframe(x, y, z, cmap=cm.viridis, rstride=1, cstride=1)
#plot the 3d line
u = np.linspace(0,4*np.pi,40)
x=1.2*np.cos(u);
y=1.2*np.sin(u);
z=u/np.pi;
ax.plot(x,y,z,'b');