Lesson 18
Creating simple graphs in Python
Big question
How can graphs make data patterns easier to see?
Lesson progress
Complete checkpoints as you learn
Learning objectives
- Explain creating simple graphs in python in plain language.
- Use scatter plot correctly in an interpretation.
- Connect the lesson idea to a formula, graph, Python result, or real example.
Simple explanation
Graphs show patterns that tables can hide. Scatter plots are especially useful in econometrics because they show how two variables move together.
Key terms
- Scatter plot
- A graph where each point represents two values for one observation.
- x-axis
- The horizontal axis, often used for an explanatory variable.
- y-axis
- The vertical axis, often used for an outcome variable.
- Trend
- A broad pattern in the plotted points.
Example
A scatter plot of education and wage can show whether higher education tends to come with higher wages.
Scatter plot
1import pandas as pd2import matplotlib.pyplot as plt3 4df = pd.read_csv("wage_sample.csv")5plt.scatter(df["education"], df["wage"])6plt.xlabel("Education")7plt.ylabel("Wage")8plt.title("Wage and education")9plt.show()Live notebook
Run this lesson as a notebook
Open an editable notebook cell-by-cell, run Python in the browser, and download the `.ipynb` file for later.
Checkpoint activity
Pause and explain this lesson's main idea in your own words before moving forward.
Try it yourself
Write one plain-English sentence explaining the main idea from this lesson.
Common mistakes
Check these before you move on.
A regression coefficient describes a pattern unless the assumptions or research design support a causal interpretation.
Quick quiz
Which graph is useful for seeing the relationship between two variables?
Key takeaway
Graphs help you see the data before you summarize it with one number.