1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Visualization with Matplotlib

Connected

Exercise

Encoding time by color

The screen only has two dimensions, but we can encode another dimension in the scatter plot using color. Here, we will visualize the climate_change dataset, plotting a scatter plot of the "co2" column, on the x-axis, against the "relative_temp" column, on the y-axis. We will encode time using the color dimension, with earlier times appearing as darker shades of blue and later times appearing as brighter shades of yellow.

Instructions

100 XP
  • Using the ax.scatter method add a scatter plot of the "co2" column (x-axis) against the "relative_temp" column.
  • Use the c key-word argument to pass in the index of the DataFrame as input to color each point according to its date.
  • Set the x-axis label to "CO2 (ppm)" and the y-axis label to "Relative temperature (C)".