Term Frequency Visualization

Chisheng Li

The repetition of terms in a State of the Union address can give insight into the issues of its era and the policies of the party in power. Below are plots of 23 keywords and their absolute frequencies used by each president.


In [1]:
%matplotlib inline
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

vis = pd.read_csv('vis.csv')

Nationalism


In [2]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
ameri = sns.barplot(x="President", y="American", hue='Party', data=vis)
fig.suptitle("Frequency of American(s) by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [3]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
free = sns.barplot(x="President", y="freedom", hue='Party', data=vis)
fig.suptitle("Frequency of Freedom by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [4]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
democ = sns.barplot(x="President", y="democracy", hue='Party', data=vis)
fig.suptitle("Frequency of Democracy by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()


Policy topics


In [5]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
wor = sns.barplot(x="President", y="world", hue='Party', data=vis)
fig.suptitle("Frequency of World by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [6]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
pea = sns.barplot(x="President", y="peace", hue='Party', data=vis)
fig.suptitle("Frequency of Peace by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [7]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
oil = sns.barplot(x="President", y="oil", hue='Party', data=vis)
fig.suptitle("Frequency of Oil by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [8]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
ener = sns.barplot(x="President", y="energy", hue='Party', data=vis)
fig.suptitle("Frequency of Energy by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [9]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
child = sns.barplot(x="President", y="children", hue='Party', data=vis)
fig.suptitle("Frequency of Children by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [10]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
educ = sns.barplot(x="President", y="education", hue='Party', data=vis)
fig.suptitle("Frequency of Education by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [11]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
secur = sns.barplot(x="President", y="security", hue='Party', data=vis)
fig.suptitle("Frequency of Security by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [12]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
war = sns.barplot(x="President", y="war", hue='Party', data=vis)
fig.suptitle("Frequency of War by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [13]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
scien = sns.barplot(x="President", y="science", hue='Party', data=vis)
fig.suptitle("Frequency of Science by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [14]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
tech = sns.barplot(x="President", y="technology", hue='Party', data=vis)
fig.suptitle("Frequency of Technology by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()


Rhetorical Terms


In [15]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
god = sns.barplot(x="President", y="God", hue='Party', data=vis)
fig.suptitle("Frequency of God by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [16]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
faith = sns.barplot(x="President", y="faith", hue='Party', data=vis)
fig.suptitle("Frequency of Faith by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [17]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
love = sns.barplot(x="President", y="love", hue='Party', data=vis)
fig.suptitle("Frequency of Love by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [18]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
hope = sns.barplot(x="President", y="hope", hue='Party', data=vis)
fig.suptitle("Frequency of Hope by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()


Economic Terms


In [19]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
econ = sns.barplot(x="President", y="economy", hue='Party', data=vis)
fig.suptitle("Frequency of Economy by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [20]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
job = sns.barplot(x="President", y="jobs", hue='Party', data=vis)
fig.suptitle("Frequency of Jobs by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [21]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
debt = sns.barplot(x="President", y="debt", hue='Party', data=vis)
fig.suptitle("Frequency of Debt by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [22]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
budg = sns.barplot(x="President", y="budget", hue='Party', data=vis)
fig.suptitle("Frequency of Budget by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [23]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
spend = sns.barplot(x="President", y="spending", hue='Party', data=vis)
fig.suptitle("Frequency of Spending by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()



In [24]:
fig = plt.figure(figsize=(15,7))
sns.set_style("whitegrid")
tax = sns.barplot(x="President", y="tax", hue='Party', data=vis)
fig.suptitle("Frequency of Tax by President", fontsize=20)
plt.ylabel("Word Frequency", fontsize=16)
plt.xlabel("Presidents", fontsize=16)
plt.xticks(rotation=90)
plt.show()