questions on multiple plots and multiple legend on python
Question: I have the following code, could any one help me fix it? I would like to have
multiple legends on python numpy / matlab graph.

    
    
     import numpy as np
        import matplotlib.pyplot as plt
        fig = plt.figure(1)
        x0 = np.array([[1,2,2,3]])
        x1 = np.array([[2,2,4,3]])
        y0 = np.array([[1,6,2,7]])
        y0 = np.array([[4,2,2,5]])
        p1= plt.scatter(x0,x1,color='blue',s=3)
        p2= plt.scatter(y0,y0,color='red',s=3)
        leg = plt.legend((p1,p2),('class0','class1'),fontsize=8)
        plt.show()
    

I want my following figure to be on the fig and have its own legend

    
    
        plt.hold(True)
        z0 = np.array([[11,16,13,17]])
        z1 = np.array([[13,16,12,17]])
        p3 = plt.scatter(z0,z1,color='k')
        plt.show()
    

How I should add a legend for `p3`?


Answer: Here I have all three scatterplots on the same figure with one legend in top-
right and the other on bottom-right.

We can get both legends to show up by adding the first legend to the axes as
described in the [matplotlib legend
guide](http://matplotlib.org/users/legend_guide.html#multiple-legends-on-the-
same-axes):

    
    
    import numpy as np
    import matplotlib.pyplot as plt
    
    fig = plt.figure(1)
    x0 = np.array([[1,2,2,3]])
    x1 = np.array([[2,2,4,3]])
    y0 = np.array([[1,6,2,7]])
    y0 = np.array([[4,2,2,5]])
    p1= plt.scatter(x0,x1,color='blue',s=50, label='class0')
    p2= plt.scatter(y0,y0,color='red',s=50, label='class1')
    z0 = np.array([[11,16,13,17]])
    z1 = np.array([[13,16,12,17]])
    p3 = plt.scatter(z0,z1,color='k', s=75, label='class3')
    
    leg = plt.legend(handles=[p1, p2], fontsize=8, loc=1)
    ax = plt.gca().add_artist(leg)
    plt.legend(handles=[p3], fontsize=8, loc=4)
    plt.show()
    

![enter image description here](http://i.stack.imgur.com/uWCZx.png)

