How to Make a Line Plot with Pandas and Matplotlib in a Jupyter Notebook

How to Create a Simple Line Plot, add Axis Labels and Title, Customize Axis Ticks, add a Second Line Plot, and add a Legend

David Allen
8 min readJun 8, 2020

--

Documentation for how to create a common visualization using Python, Jupyter Notebook, and Pandas.

This documentation assumes some familiarity with these tools, but not too much. You really just need to be able to get a notebook open and use a keyboard to succeed here.

Let’s dive in!

Table of Contents:

  1. Getting Set up
  2. Grab Data, Create Dataframe
  3. Filter Dataframe using .loc
  4. Plot Line
  5. Change Figure Size
  6. Customize Ticks with set_major_locator
  7. Add Axis Labels and Title
  8. Plot 2nd Line
  9. Add Legend Labels

Step 1: Getting Set Up

--

--

David Allen

Documentation and tutorials on Python, Pandas, Jupyter Notebook, and Data Analysis.