How can I draw a multiple image of 3d curves in Python?

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  #t can be changed

fig = plt.figure()
ax=Axes3D(fig)

#data

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            ######step 
#########data#################
xs = np.empty((stepCnt + 1,))
ys = np.empty((stepCnt + 1,))
zs = np.empty((stepCnt + 1,))

#Setting initial values
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')

enter image description here

0
source share
1 answer

In your image, it looks like a blue line, but it is hidden behind the red line (you can see the blue corners sticking out of the red circles). Try changing the data on the blue line and you can see it.

0
source

Source: https://habr.com/ru/post/1681810/


All Articles