Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Вивчайте Visualizing Economic Data with matplotlib | Economic Data Analysis with Python
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Economists

bookVisualizing Economic Data with matplotlib

Data visualization is a cornerstone of economic analysis, allowing you to interpret and communicate complex trends in a clear and persuasive way. In economics, visual tools help you quickly spot patterns, compare indicators across countries, and make informed decisions based on empirical evidence. Whether you are tracking GDP growth, unemployment rates, or inflation, effective visualizations transform raw data into actionable insights.

12345678910111213141516171819202122232425
import matplotlib.pyplot as plt import pandas as pd # Sample GDP data (in billions USD) data = { "Year": [2015, 2016, 2017, 2018, 2019, 2020], "USA": [18224, 18707, 19485, 20612, 21433, 21138], "Germany": [3371, 3479, 3650, 3948, 3861, 3806], "Japan": [4384, 4939, 4850, 4971, 5082, 5065] } df = pd.DataFrame(data) plt.figure(figsize=(8, 5)) plt.plot(df["Year"], df["USA"], label="USA", marker="o") plt.plot(df["Year"], df["Germany"], label="Germany", marker="o") plt.plot(df["Year"], df["Japan"], label="Japan", marker="o") plt.xlabel("Year") plt.ylabel("GDP (Billions USD)") plt.title("GDP Over Time (2015-2020)") plt.legend() plt.grid(True) plt.tight_layout() plt.show()
copy

This line plot shows GDP over time for the USA, Germany, and Japan. The horizontal axis (x-axis) represents the years, while the vertical axis (y-axis) shows GDP in billions of USD. Each country is represented by a line with distinct markers, and the legend identifies which line corresponds to which country. Labels on the axes ensure you know what each dimension represents, while the title provides context for the plot. By observing the slopes and relative positions of the lines, you can quickly compare economic growth and spot trends, such as steady increases or periods of decline.

12345678910111213
import matplotlib.pyplot as plt # Sample unemployment data for 2020 countries = ["USA", "Germany", "Japan"] unemployment_rates = [8.1, 4.2, 2.8] plt.figure(figsize=(6, 4)) plt.bar(countries, unemployment_rates, color=["royalblue", "darkorange", "seagreen"]) plt.xlabel("Country") plt.ylabel("Unemployment Rate (%)") plt.title("Unemployment Rates in 2020") plt.tight_layout() plt.show()
copy

1. What type of plot is best for showing changes in GDP over time?

2. Fill in the blank: To add a legend to a matplotlib plot, you would use _ _ _.

3. Why is it important to label axes in economic data visualizations?

question mark

What type of plot is best for showing changes in GDP over time?

Select the correct answer

question-icon

Fill in the blank: To add a legend to a matplotlib plot, you would use _ _ _.

question mark

Why is it important to label axes in economic data visualizations?

Select the correct answer

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

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

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

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

Запитати АІ

expand

Запитати АІ

ChatGPT

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

Suggested prompts:

Can you explain how to interpret the bar chart for unemployment rates?

What other economic indicators can be visualized similarly?

Can you suggest ways to compare more countries or years in these visualizations?

bookVisualizing Economic Data with matplotlib

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

Data visualization is a cornerstone of economic analysis, allowing you to interpret and communicate complex trends in a clear and persuasive way. In economics, visual tools help you quickly spot patterns, compare indicators across countries, and make informed decisions based on empirical evidence. Whether you are tracking GDP growth, unemployment rates, or inflation, effective visualizations transform raw data into actionable insights.

12345678910111213141516171819202122232425
import matplotlib.pyplot as plt import pandas as pd # Sample GDP data (in billions USD) data = { "Year": [2015, 2016, 2017, 2018, 2019, 2020], "USA": [18224, 18707, 19485, 20612, 21433, 21138], "Germany": [3371, 3479, 3650, 3948, 3861, 3806], "Japan": [4384, 4939, 4850, 4971, 5082, 5065] } df = pd.DataFrame(data) plt.figure(figsize=(8, 5)) plt.plot(df["Year"], df["USA"], label="USA", marker="o") plt.plot(df["Year"], df["Germany"], label="Germany", marker="o") plt.plot(df["Year"], df["Japan"], label="Japan", marker="o") plt.xlabel("Year") plt.ylabel("GDP (Billions USD)") plt.title("GDP Over Time (2015-2020)") plt.legend() plt.grid(True) plt.tight_layout() plt.show()
copy

This line plot shows GDP over time for the USA, Germany, and Japan. The horizontal axis (x-axis) represents the years, while the vertical axis (y-axis) shows GDP in billions of USD. Each country is represented by a line with distinct markers, and the legend identifies which line corresponds to which country. Labels on the axes ensure you know what each dimension represents, while the title provides context for the plot. By observing the slopes and relative positions of the lines, you can quickly compare economic growth and spot trends, such as steady increases or periods of decline.

12345678910111213
import matplotlib.pyplot as plt # Sample unemployment data for 2020 countries = ["USA", "Germany", "Japan"] unemployment_rates = [8.1, 4.2, 2.8] plt.figure(figsize=(6, 4)) plt.bar(countries, unemployment_rates, color=["royalblue", "darkorange", "seagreen"]) plt.xlabel("Country") plt.ylabel("Unemployment Rate (%)") plt.title("Unemployment Rates in 2020") plt.tight_layout() plt.show()
copy

1. What type of plot is best for showing changes in GDP over time?

2. Fill in the blank: To add a legend to a matplotlib plot, you would use _ _ _.

3. Why is it important to label axes in economic data visualizations?

question mark

What type of plot is best for showing changes in GDP over time?

Select the correct answer

question-icon

Fill in the blank: To add a legend to a matplotlib plot, you would use _ _ _.

question mark

Why is it important to label axes in economic data visualizations?

Select the correct answer

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

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

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

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