1

How to add line to this grph that would be parallel to axis pointing up? I tried:

plt.plot([0, 1, 1],[0, 1.5, 1.5]) 

but is connect not the desired points. I am really confuse from coordinates. They rapidly change then I point mause in two closely places.

import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

fig = plt.figure(figsize=[5,3])
ax = fig.gca(projection = '3d')


ax.set_ylim(0,3)
ax.set_zlim(0,2)
# ax.set_xlim(0,2)

vleng = 5
aleng = vleng/3.

p = np.array([vleng+200, 0, 0])
q = np.array([0, vleng-2, 0])
r = np.array([0, 0, vleng-3])

ax.plot(*np.vstack([[0,0,0], p]).T, color='black')
ax.plot(*np.vstack([[0,0,0], q]).T, color='black')
ax.plot(*np.vstack([[0,0,0], r]).T, color='black')

ax.azim = 20    # y rotation (default=270)
ax.elev = 20    # x rotation (default=0)
ax.dist = 10    # zoom (define perspective)

ax.set_axis_off( )  # hide all grid

plt.tight_layout(pad=0)
plt.show()
Moe
  • 301
  • 2
  • 11

1 Answers1

3

Your inputs are wrong. Use a list or numpy array for each dimension. For your case:

ax.plot([0, 0], # x
        [1, 1], # y
        [0, 1]) # z 

See

Joe
  • 6,758
  • 2
  • 26
  • 47