Plotting scatterplots for relationships in data

Scatterplots plot two variables as points on a plane, and they can help you figure out the relationship between the two variables. They are also quite effective if you want to represent groups and clusters. In our example, we will create three data clusters and represent them in a scatterplot with different shapes and colors:

In: from sklearn.datasets import make_blobs    import matplotlib.pyplot as plt    D = make_blobs(n_samples=100, n_features=2,                    centers=3, random_state=7)    groups = D[1]    coordinates = D[0]  

Since we have to plot three different groups, we will have to use three distinct plot commands. Each command specifies a different color and shape (the 'ys', 'm*', 'rD' strings, where the first ...

Get Python Data Science Essentials - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.