1. Learn
  2. /
  3. Courses
  4. /
  5. Improving Your Data Visualizations in Python

Exercise

Arrow annotations

Imagine you are a city planner for Long Beach, California. Long Beach is located on the Pacific Ocean and has a large firework show every New Year's Eve. You want to look into whether this show negatively impacts the air quality of the city. To do this, you will look at CO and NO2 levels on New Year's Day. However, it turns out that New Year's Day is not one of the outliers in the plot on the right, it's located in one of the more crowded areas.

To help guide the reader to this point, you'll use an annotation along with an arrow that points to the New Year's Day value. This will provide a nice annotation that explains what the viewer is looking while printing the text in a less crowded region of the plot.

Instructions

100 XP
  • Grab the row from jan_pollution that corresponds to New Year's Day 2012 in the city of Long Beach using the pandas' .query() method.
  • Set the endpoint of the arrow (xy) by using the CO and NO2 column values from the lb_newyears DataFrame.
  • Use the argument xytext to place the annotation arrow's text in the bottom left corner of the display at x = 2, y = 15.
  • 'shrink' the arrow to 0.03, so it doesn't occlude the point of interest.