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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.