Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Adding One More Line | Basics: Line Charts
Visualization in Python with matplotlib

bookAdding One More Line

Quite good! That's a good visualization! Let's expand our chart with new data.

We may want to compare the emission levels by displaying several lines on a single chart. It can be easily done by calling the .plot() method of Axes object multiple times. For instance, if you call ax.plot() two times, you will get two lines on one chart. By default, the first line will be blue, the second one will be orange.

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd # Load the data data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/co2.csv', index_col = 0) # Filter the data ita = data.loc['Italy'] swe = data.loc['Sweden'] # Create Figure and Axes objects fig, ax = plt.subplots() # Initialize lines ax.plot(ita.index.astype(int), ita.values) ax.plot(swe.index.astype(int), swe.values) # Display the plot plt.show()
copy

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4

Запитати АІ

expand

Запитати АІ

ChatGPT

Запитайте про що завгодно або спробуйте одне із запропонованих запитань, щоб почати наш чат

Awesome!

Completion rate improved to 2.94

bookAdding One More Line

Свайпніть щоб показати меню

Quite good! That's a good visualization! Let's expand our chart with new data.

We may want to compare the emission levels by displaying several lines on a single chart. It can be easily done by calling the .plot() method of Axes object multiple times. For instance, if you call ax.plot() two times, you will get two lines on one chart. By default, the first line will be blue, the second one will be orange.

1234567891011121314151617181920
# Import the libraries import matplotlib.pyplot as plt import pandas as pd # Load the data data = pd.read_csv('https://codefinity-content-media.s3.eu-west-1.amazonaws.com/ed80401e-2684-4bc4-a077-99d13a386ac7/co2.csv', index_col = 0) # Filter the data ita = data.loc['Italy'] swe = data.loc['Sweden'] # Create Figure and Axes objects fig, ax = plt.subplots() # Initialize lines ax.plot(ita.index.astype(int), ita.values) ax.plot(swe.index.astype(int), swe.values) # Display the plot plt.show()
copy

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 1. Розділ 4
some-alt