def ply_save_color_pcloud(path, pcloud, color):
    """
  Save point cloud into a .ply file with per-point color.

  Parameters
  ----------
  path : str
    Path to save the file.
  pcloud : np.ndarray, shape [n, 3]
    Point cloud to save.
  color : np.ndarray, shape [n, 3], dtype uint8
    Color for each point.
  """
    num_points = pcloud.shape[0]
    with open(path, 'wb') as f:
        f.write(b'ply\n')
        f.write(b'format ascii 1.0\n')
        f.write(b'element vertex %d\n' % num_points)
        f.write(b'property float32 x\n')
        f.write(b'property float32 y\n')
        f.write(b'property float32 z\n')
        f.write(b'property uchar red\n')
        f.write(b'property uchar green\n')
        f.write(b'property uchar blue\n')
        f.write(b'end_header\n')
        for i in range(num_points):
            v = pcloud[i]
            c = color[i]
            f.write(b'%f %f %f %d %d %d\n' % (v[0], v[1], v[2], c[0], c[1],
                c[2]))
