plot data in 3D

def plot_data(orig_data, data):
    '''plot data in 3D'''
    import numpy as np
    from mpl_toolkits.mplot3d import Axes3D
    import matplotlib.pyplot as plt

    for dd, c in [(orig_data, 'r'), (data, 'b')]:
        fig = plt.figure()
        ax = fig.add_subplot(111, projection='3d')

        xs = [ d.x for d in dd ]
        ys = [ d.y for d in dd ]
        zs = [ d.z for d in dd ]
        ax.scatter(xs, ys, zs, c=c, marker='o')

        ax.set_xlabel('X Label')
        ax.set_ylabel('Y Label')
        ax.set_zlabel('Z Label')
    plt.show()