Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Create a Simple Line Chart | Basics: Line Charts
Visualization in Python with matplotlib
course content

Course Content

Visualization in Python with matplotlib

Visualization in Python with matplotlib

1. Basics: Line Charts
2. Bar Charts
3. Scatter Plots

bookCreate a Simple Line Chart

Task

Build a line chart representing the level of CO2 emissions (metric tonnes of CO2 per person) for the US. Follow the next steps:

  1. Import the matplotlib.pyplot under the plt alias.
  2. Save the United States data in the usa variable.
  3. Create Figure and Axes objects using the .subplots() method of plt and assign them to variables fig, and ax, respectively.
  4. Initialize a line chart:
    • display years on the x-axis (use the .index attribute), convert them to integers (int);
    • display level of emissions on the y-axis (use the .values attribute).
  5. Display the plot.

Once you've completed this task, click the button below the code to check your solution.

Disclaimer: FREE DATA FROM WORLD BANK VIA GAPMINDER.ORG, CC-BY LICENSE.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 3
toggle bottom row

bookCreate a Simple Line Chart

Task

Build a line chart representing the level of CO2 emissions (metric tonnes of CO2 per person) for the US. Follow the next steps:

  1. Import the matplotlib.pyplot under the plt alias.
  2. Save the United States data in the usa variable.
  3. Create Figure and Axes objects using the .subplots() method of plt and assign them to variables fig, and ax, respectively.
  4. Initialize a line chart:
    • display years on the x-axis (use the .index attribute), convert them to integers (int);
    • display level of emissions on the y-axis (use the .values attribute).
  5. Display the plot.

Once you've completed this task, click the button below the code to check your solution.

Disclaimer: FREE DATA FROM WORLD BANK VIA GAPMINDER.ORG, CC-BY LICENSE.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 1. Chapter 3
toggle bottom row

bookCreate a Simple Line Chart

Task

Build a line chart representing the level of CO2 emissions (metric tonnes of CO2 per person) for the US. Follow the next steps:

  1. Import the matplotlib.pyplot under the plt alias.
  2. Save the United States data in the usa variable.
  3. Create Figure and Axes objects using the .subplots() method of plt and assign them to variables fig, and ax, respectively.
  4. Initialize a line chart:
    • display years on the x-axis (use the .index attribute), convert them to integers (int);
    • display level of emissions on the y-axis (use the .values attribute).
  5. Display the plot.

Once you've completed this task, click the button below the code to check your solution.

Disclaimer: FREE DATA FROM WORLD BANK VIA GAPMINDER.ORG, CC-BY LICENSE.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Task

Build a line chart representing the level of CO2 emissions (metric tonnes of CO2 per person) for the US. Follow the next steps:

  1. Import the matplotlib.pyplot under the plt alias.
  2. Save the United States data in the usa variable.
  3. Create Figure and Axes objects using the .subplots() method of plt and assign them to variables fig, and ax, respectively.
  4. Initialize a line chart:
    • display years on the x-axis (use the .index attribute), convert them to integers (int);
    • display level of emissions on the y-axis (use the .values attribute).
  5. Display the plot.

Once you've completed this task, click the button below the code to check your solution.

Disclaimer: FREE DATA FROM WORLD BANK VIA GAPMINDER.ORG, CC-BY LICENSE.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 1. Chapter 3
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt