12.4 Using axes directly to create a scatter plot
Many ordinary graphics visualizations can be done using the functions available directly in the pyplot module. In the previous recipes, we used the scatter() function to draw a scatter plot showing the relationship between two variables. Other functions like bar(), pie(), and hist() will create other kinds of plots from our raw data. However, there are times when the readily available functions on the pyplot module aren’t completely appropriate, and we’d like to do a few more things in our images.
In this recipe, we’ll add a legend box to each of the sub-plots to show the linear regression parameters that fit the scatter-plot data.
In the Ingesting data into a notebook recipe, we looked at a collection of data that had four series of data. The file that contained this data is named anscombe.json. Each series of data is a dictionary with a sequence of (x,y) data pairs, and a name for the...