I want to draw two space curves in one picture using Python.
So, I use two Axes3D.plot for drawing curves. But the resulting picture simply shows the latter. If I use Axes3D.scatter, it can display all points.
Here are my codes:
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import math as mt
from mpl_toolkits.mplot3d import Axes3D
t=2
fig = plt.figure()
ax=Axes3D(fig)
def unitilize(x,y,z):
r=mt.sqrt(x**2+y**2+z**2)
return x/r, y/r, z/r
def g_1(x,y,z):
x=t*x
z=z/t
x,y,z=unitilize(x,y,z)
return x,y,z
stepCnt=10000
xs = np.empty((stepCnt + 1,))
ys = np.empty((stepCnt + 1,))
zs = np.empty((stepCnt + 1,))
def huatu(x,y,z):
xs[0], ys[0], zs[0] =unitilize(x,y,z)
for i in range(stepCnt):
xs[i+1],ys[i+1],zs[i+1]=g_1(xs[i], ys[i], zs[i])
return xs,ys,zs
xs3,ys3,zs3=huatu(1,10,40)
ax.plot(xs3, ys3, zs3, color='b', marker='x')
xs2,ys2,zs2=huatu(1,0,40)
ax.plot(xs2, ys2, zs2, color='r', marker='o')
