how to do multiple scatter plots with matploatlib

You are a Udacity Machine Learning student?

Something like this might be useful for you:

import numpy as np
import matplotlib.pyplot as plt

labels = ['output','varA','varB','varC']

data = np.array([[4,5,6,2,5],
                [3,6,4,6,3],
                [12,3,5,3,2],
                [4,1,1,44, 7]])

colors = ["r", "g", "b", "k"] # make sure you have enough colors to match 
                              # the number of variables
for i in range(1, len(data)):
    plt.scatter(data[1], data[i], c=colors[i-1], s=100, alpha=0.7, label=labels[i])
plt.legend()
plt.show()

Hope that helps.

Ronny

Leave a Comment