Get startedGet started for free

Your first plot!

Let's take everything you have learned so far and plot your first time series plot. You will set the groundwork by producing a time series plot of your data and labeling the axes of your plot, as this makes the plot more readable and interpretable for the intended audience.

matplotlib is the most widely used plotting library in Python, and would be the most appropriate tool for this job. Fortunately for us, the pandas library has implemented a .plot() method on Series and DataFrame objects that is a wrapper around matplotlib.pyplot.plot(), which makes it easier to produce plots.

This exercise is part of the course

Visualizing Time Series Data in Python

View Course

Exercise instructions

  • Set the 'date' column as the index of your DataFrame.
  • Using the discoveries DataFrame, plot the time series in your DataFrame using a "blue" line plot and assign it to ax.
  • Specify the x-axis label on your plot: 'Date'.
  • Specify the y-axis label on your plot: 'Number of great discoveries'.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# Set the date column as the index of your DataFrame discoveries
discoveries = ____

# Plot the time series in your DataFrame
ax = discoveries.____(____=____)

# Specify the x-axis label in your plot
____('Date')

# Specify the y-axis label in your plot
____('Number of great discoveries')

# Show plot
plt.show()
Edit and Run Code