Make a Line Chart
Lesson 1 of 2
  1. 1
    There are many different tools for making data visualizations in Python, but some of the most common are - Jupyter Notebooks for running code and viewing results - pandas for loading and o…
  2. 2
    Welcome to this lesson on matplotlib! As we just learned, matplotlib is a Python library used for making graphs. It’s commonly used by research scientists and data scientists, among other professio…
  3. 3
    Before we jump into making a line chart, let’s take a step back and learn about five common chart types in data visualization, and how we make them appear in matplotlib. Each graph that can be mad…
  4. 4
    As we saw in the last exercise, each graph in matplotlib is made using the specific graph function for that graph. Inside the parentheses of the function, we put arguments that are specific to …
  5. 5
    Okay, we’ve covered some basics on matplotlib syntax and seen how graphs are made and altered. Now let’s make a chart ourselves! In the next few exercises we’ll focus on making a line chart to comp…
  6. 6
    We created a basic line chart just by supplying x and y parameters to the .plot() function. Once we have more than one line in the chart, matplotlib will automatically style them with different col…
  7. 7
    This graph is starting to get interesting! It’s pretty hard to interpret, though, so let’s add a title and legend. When we set the parameters for our line chart and changed line formatting, we did…
  8. 8
    Finally, let’s fix up a couple loose ends on this graph to make it look finished and intentional. Our lines, title, and legend are good to go, but the axes aren’t labeled, and the overlapping tick …
  9. 9
    Wow, we covered a lot! Let’s export our finished line chart. To export a chart, we just call the function plt.savefig(), giving the filename we want as an argument. So, to save a line chart as ‘my…
  10. 10
    Nice work, we’ve made it to the end of this lesson! We learned about the general structure of charts in matplotlib and made a line chart from start to finish. We learned that… * general functions…

What you'll create

Portfolio projects that showcase your new skills

How you'll master it

Stress-test your knowledge with quizzes that help commit syntax to memory