CommencerCommencer gratuitement

A basic text annotation

On the current scatter plot, you can see a particularly prominent point that contains the largest SO2 value observed for August. This point is Cincinnati on August 11th, 2013; however, you would not be able to learn this information from the plot in its current form. Basic text annotations are great for pointing out interesting outliers and giving a bit more information. Draw the readers attention to this Cincinnati value by adding a basic text annotation that gives a bit of the background about this outlier.

Cet exercice fait partie du cours

Improving Your Data Visualizations in Python

Afficher le cours

Instructions

  • Filter the data plotted in scatter plot to just August.
  • Draw text annotation at x = 0.57 and y = 41 to call out the highest SO2 value.
  • Label annotation with 'Cincinnati had highest observed\nSO2 value on Aug 11, 2013' (note the line break).
  • Change the font-size to 'large' for the annotation.

Exercice interactif pratique

Essayez cet exercice en complétant cet exemple de code.

# Draw basic scatter plot of pollution data for August
sns.scatterplot(x = 'CO', y = 'SO2', data = pollution[pollution.month  ==  ____])

# Label highest SO2 value with text annotation
plt.text(____, ____,
         '____', 
         # Set the font to large
         fontdict = {'ha': 'left', '____': '____'})
plt.show()
Modifier et exécuter le code