Good job. Naturally,
matplotlib offers numerous other types of plots. Scatter plots are a frequent choice for many analysts. Creating them with matplotlib is very similar to creating histograms or line plots, so we won’t explain everything from scratch here. Instead, take a look at the example below:
umbrellas = pd.read_csv('umbrellas.csv')
scatter_figure = plt.figure(figsize=(10, 5))
scatter_subplot = plt.subplot(111)
scatter_subplot.set_title('Umbrella Sales by Rainfall')
plt.scatter(umbrellas['rainfall'], umbrellas['sales'], c='blue', alpha=0.5, s=120, marker='^')
Take a look at the last line above. Our
plt.scatter takes the following two obligatory arguments:
umbrellas['rainfall'] – x-axis data,
umbrellas['sales'] – y-axis data.
We also added some optional arguments:
c='blue' means our points will be of colored blue,
alpha=0.5 means our points will be 50% transparent,
s=120 defines the size of our points,
marker='^' means that each point will be shown as a triangle.