1. Learn
  2. /
  3. Courses
  4. /
  5. Visualizing Time Series Data in Python

Exercise

Display and label plots

As you saw earlier, if the index of a pandas DataFrame consists of dates, then pandas will automatically format the x-axis in a human-readable way. In addition the .plot() method allows you to specify various other parameters to tailor your time series plot (color of the lines, width of the lines and figure size).

You may have noticed the use of the notation ax = df.plot(...) and wondered about the purpose of the ax object. This is because the plot function returns a matplotlib AxesSubplot object, and it is common practice to assign this returned object to a variable called ax. Doing so also allows you to include additional notations and specifications to your plot such as axis labels.

Instructions

100 XP

Display a line chart of the discoveries DataFrame.

  • Specify the color of the line as 'blue'.
  • Width of the line as 2.
  • The dimensions of your plot to be of length 8 and width 3.
  • Specify the fontsize of 6.