Plotting points based on what value they end up being in matplotlib and numpy
Question: I apologize, since I don't exactly know how to word my title. I'm brand new to
Python and especially new to matplotlib. I am also using numpy for my arrays
in this case.

Currently, I have a set of data: `X` that has four properties. Each property
is a column, and each row is a set of data points (lets just say they are
represented by numbers for now). Here is a small example:

    
    
    X
    (height)  (weight)  (gender)  (hair color)
    6           32.1        0           12
    1.112       6.12        1           9
    4            2          0           6    
    2            3.2        0           11
    

I also have an array `Y` that corresponds to an integer value from 0 - 2. It
is just an `np.array` but each element corresponds to that row of values in
`X`. So for example if `Y = array([0,2,1,1])` then I have these pairs:

    
    
    Y          X
    0 -> (6, 32.1, 0, 12)
    2 -> (1.112, 6.12, 1, 9)
    1 -> (4, 2, 0, 6)
    1 -> (2, 3.2, 0, 11)
    

What I want to do is create **separate** scatter plots for each pair of these
properties:

    
    
    (height, weight) -> (0,1)
    (height, gender) -> (0,2)
    (height, hair color) -> (0, 3)
    

And I want each data point to have a color that corresponds with the `Y`
value. So `y = 0 = 'b'`, `y = 1 = 'g'`, and `y = 2 = 'r'`

I know how to create a scatter plot (in this case, just the height and weight
column) that will map the pairs that I want using

    
    
    plt.plot(X[:,0], X[:,1], 'o', c='b')
    plt.show()
    

However I don't know how I can then relate each of these points to the `Y`
value that holds its color, since I can only input one color. I would
appreciate any help, or tutorials that could guide me in the right direction.


Answer: You could map Y to rgb colors and use "scatter" to plot points with different
colors:

    
    
    import numpy
    from matplotlib import pyplot as plt
    
    X = numpy.array([[6, 32.1, 0, 12],
        [1.112, 6.12, 1, 9],
        [4, 2, 0, 6],
        [2, 3.2, 0, 11]])
    
    Y = numpy.array([0, 1, 1, 2])
    
    # map numbers to rgb colors
    Y_color = numpy.zeros(shape=(Y.size, 3))
    Y_color[Y == 0] = (1,0,0)
    Y_color[Y == 1] = (0,1,0)
    Y_color[Y == 2] = (0,0,1)
    
    # use scatter instead of plot
    plt.scatter(X[:,0], X[:,1], c=Y_color)
    plt.show()
    

