Reputation: 1585
I am trying to plot a straight line on the 3D surface (x,y,z) along the base of this plot from (1,3,0) to (1,6,0). The straight line along the x plane is not plotting and I can't seem to figure out what my error is. I have found a few similar questions to this but couldn't find where my mistake is.
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# points
z = np.repeat(0.1, 100)
x = np.repeat(1.0, 100)
y = np.linspace(start=3.0, stop=6.0, num=100)
# set axes limits
ax.set_xlim(6,3)
ax.set_ylim(0,1.1)
ax.set_zlim(0,1.75)
# plot
ax.plot(x, y, z, c='red',label=r'straight line at $x=1.0$')
plt.show()
I am holding x and z fixed while changing the y coordinates.
Upvotes: 2
Views: 985
Reputation: 197
You have (likely accidentally) switched the x-axis and y-axis limits. Try this
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
# points
z = np.repeat(0.1, 100)
x = np.repeat(1.0, 100)
y = np.linspace(start=3.0, stop=6.0, num=100)
# set axes limits
ax.set_xlim(0,1.1)
ax.set_ylim(6,3)
ax.set_zlim(0,1.75)
# plot
ax.plot(x, y, z, c='red',label=r'straight line at $x=1.0$')
plt.show()
Upvotes: 1