Plotting Data using Matplotlib
Scatter and box plots
Draw scatter and box plots and read their meaning.
A scatter chart shows the relationship between two variables: each data point is a dot, placed by its x and y values. (Scatter charts are sometimes called correlation plots.) The dots' size or colour can show a third variable.
- With Pyplot: plt.scatter(x=, y=, s=size, color=, marker=). The s parameter sets the size of each dot ('bubble').
- With Pandas: df.plot(kind='scatter', x='col1', y='col2'): x and y must be given.
Quartiles divide ordered data into four equal parts. The second quartile is the median.
A box plot (box and whisker plot) shows five numbers: the minimum, the first quartile, the median, the third quartile and the maximum. The box covers the middle half of the data, and the whiskers stretch towards the minimum and maximum. Dots beyond the whiskers are outliers: unusually high or low values.
vert=False draws a box plot horizontally. Dots show relationships; boxes show spread.
Practise this lesson
Questions that get harder as you improve, a Tutor that helps without giving the answer away, and progress you can see. Free for every learner.
No account, no email address. Opens the real product.