Skip to content

Instantly share code, notes, and snippets.

@papachristoumarios
Created March 12, 2017 15:50
Show Gist options
  • Save papachristoumarios/332cb0d8674c670eccf0f59a2fbd24b9 to your computer and use it in GitHub Desktop.
Save papachristoumarios/332cb0d8674c670eccf0f59a2fbd24b9 to your computer and use it in GitHub Desktop.
A simple PLY pointcloud plotter in Python with matplotilib and numpy
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
def get_pts(infile):
data = np.loadtxt(infile, delimiter=',')
return data[12:,0], data[12:,1], data[12:,2] #returns X,Y,Z points skipping the first 12 lines
def plot_ply(infile):
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
x,y,z = get_pts(infile)
ax.scatter(x, y, z, c='r', marker='o')
ax.set_xlabel('X Label')
ax.set_ylabel('Y Label')
ax.set_zlabel('Z Label')
plt.show()
if __name__ == '__main__':
infile = 'pointcloud.ply'
plot_ply(infile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment