How to fix tilted point cloud?

I had tried the Plane segmentation(RANSAC) sample code and generated a pair of plane_model, inliers.
How could I use plane_model or inliers as the ground horizontal plane(z=0) while aligning the whole point cloud structure correctly?

This problem corresponds to finding the necessary translation and rotation to transform the plane to the XY plane. You may find the equations here: https://math.stackexchange.com/questions/1167717/transform-a-plane-to-the-xy-plane
The numbers in the plane_model array ([a, b, c, d]) correspond to the coefficients in the plane equation ax + by + cz + d = 0.

Apply the translation and rotation to the entire point cloud (see http://www.open3d.org/docs/release/tutorial/Basic/transformation.html for a reference).
Note that Open3D provides a convenience function to get the rotation matrix from an axis-angle representation (open3d.geometry.get_rotation_matrix_from_axis_angle).