How Can I Connect Points On A 3d Scatter Plot?
So currently, I have all these coordinates and so it's quite easy to create a 3D scatter plot of all the combination of coordinates. fig = plt.figure(figsize=(20,10)) ax = plt.axes
Solution 1:
If you have enough points using only your coordinates I think what you are looking for is plot3D
. If you need it more smooth line it might be worth looking into scipy.interpolate.RegularGridInterpolator
which would help generate more points, which you could then insert into plot3D
.
Example of usage of plot3D
:
import numpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
fig = plt.figure(figsize=(20,10))
ax = plt.axes(projection='3d')
z_coords_row = numpy.sin(numpy.linspace(0,2*numpy.pi,100))+5
x_coords_row = numpy.sin(numpy.linspace(0,2*numpy.pi,100))
y_coords_row = numpy.cos(numpy.linspace(0,2*numpy.pi,100))
z = numpy.transpose(z_coords_row)[0:100]
x = numpy.transpose(x_coords_row)[0:100]
y = numpy.transpose(y_coords_row)[0:100]
plt.xticks(numpy.arange(-1.5, 1.5, .25))
plt.yticks(numpy.arange(-1.5, 1.5, .5))
ax.scatter(x, y, z,s=5)
ax.plot3D(x,y,z)
ax.view_init(elev=10., azim=45)
Post a Comment for "How Can I Connect Points On A 3d Scatter Plot?"