I have a 3D plot in python which I made using ax.scatter(x,y,z,c='r',s=100)
from the
import matplotlib.pyplot as plt
import pylab
from mpl_toolkits.mplot3d import Axes3D.
I want to connect my points with a line. I know you can do it with marker='-o'
but that works only in 2D for me and not 3D. Can anyone help ?
Thank you.
Scatter does not allow for connecting points. The argument marker='-o'
only works for plot
, not for scatter
. That is true for 2D and 3D. But of course you can use a scatter and a plot
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
ax = plt.gca(projection="3d")
x,y,z = [1,1.5,3],[1,2.4,3],[3.4,1.4,1]
ax.scatter(x,y,z, c='r',s=100)
ax.plot(x,y,z, color='r')
plt.show()