Week 5 HW

Author
Affiliation

Ben Akyrueklier

George Washington University

Published

September 30, 2025

Code
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import altair as alt
from sklearn.datasets import load_iris
import plotly.express as px
import plotly.io as pio
pio.renderers.default='plotly_mimetype+notebook_connected'

image.png
Code
ds = pd.read_csv("data/unemployment.csv")
ds
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
0 2009 7.8 8.3 8.7 9.0 9.4 9.5 9.5 9.6 9.8 10.0 9.9 9.9
1 2010 9.8 9.8 9.9 9.9 9.6 9.4 9.4 9.5 9.5 9.4 9.8 9.3
2 2011 9.1 9.0 9.0 9.1 9.0 9.1 9.0 9.0 9.0 8.8 8.6 8.5
3 2012 8.3 8.3 8.2 8.2 8.2 8.2 8.2 8.1 7.8 7.8 7.7 7.9
4 2013 8.0 7.7 7.5 7.6 7.5 7.5 7.3 7.2 7.2 7.2 6.9 6.7
Code
dsm= ds.melt(id_vars=['Year'], var_name='Month', value_name='Value')
ds11m= dsm[dsm['Year']==2011]
ds11m.head()
Year Month Value
2 2011 Jan 9.1
7 2011 Feb 9.0
12 2011 Mar 9.0
17 2011 Apr 9.1
22 2011 May 9.0
Code
ds11m.plot(x='Month', y='Value', marker='o', color='red', legend=None, title="U.S. Unemployment Rate (2011) Truncated Y-Axis")
plt.xlabel("Month")
plt.ylabel("Unemployment Rate (%)")
plt.fill_between(x, y, color='red', alpha=0.5)
plt.ylim(8, 10)
plt.grid(True)
plt.show()

ds11m.plot(x='Month', y='Value', marker='o', color='red', legend=None, title="U.S. Unemployment Rate (2011)")
plt.xlabel("Month")
plt.ylabel("Unemployment Rate (%)")
plt.fill_between(x, y, color='red', alpha=0.5)
plt.ylim(0, 10)
plt.grid(True)
plt.show()

Code
plt.figure(figsize=(6,4))
sns.lineplot(data=dsm, x="Month", y="Value", hue="Year", marker="o", palette="pastel")
plt.legend(title="Year", bbox_to_anchor=(1.05, 1), loc='upper left')
plt.title("U.S. Unemployment Rate (2009-2013) Truncated Y-Axis")
plt.xlabel("Month")
plt.ylabel("Unemployment Rate (%)")

plt.figure(figsize=(6,4))
sns.lineplot(data=dsm, x="Month", y="Value", hue="Year", marker="o", palette="pastel")
plt.legend(title="Year", bbox_to_anchor=(1.05, 1), loc='upper left')
plt.title("U.S. Unemployment Rate (2009-2013)")
plt.xlabel("Month")
plt.ylabel("Unemployment Rate (%)")
plt.ylim(0, 10.65)

Reflection:

The original graphic was not exactly misleading, nor was it ineffective. Just because the Y-axis is truncated, it does not mean the graph is bad, and in this case it actually makes sense. THis is because there will always be unemployment in the economy for a multitude of reasons the government cannot control. However, I still wanted to show a different perspective, one that showed the 2011 data in contrast to the surrounding years, and another that did not cut the Y-axis down to the minimum point. My redsign improves comprehension because it always the viewer to see more information and a more hollistic picture of what was happening at this time.


Source: U.S. Bureau of Labor Statistics