Storytelling With Your Graphs In R Using ggplot2
By: Dylan Anderson
Tags: R, US Politics, President, Storytelling, Data Visualization

Step 5: Graphing Individual Presidential Approval Ratings

If you looked at my last post, you might notice individual presidential approval rating plots that include descriptors about major events in their presidency. This goes back to the first two points about storytelling: 1) Use text, and 2) Know your Audience. These graphs do wonders explaining why approval ratings rise and fall, without any additional captions, explanations or anything, all you need is the visual!

Below I will show you to graph a few of these past presidents, but feel free to make your own with any others.

So let’s start with Nixon’s graph with a few key moments:

nixon.plot <- df2 %>%

filter(president == "Nixon") %>%

ggplot(aes(x = date, y = approval, color = "green")) +

geom_point(alpha=0.7, color = "green") +

geom_smooth(span = 0.5, alpha = 0.5, color = "green") +

geom_vline(xintercept = as.numeric(as.Date(c("1969-6-8", "1972-11-7", "1972-6-17", "1974-08-08", "1973-4-30"))), linetype= 4, color = "black", size=0.5) +

labs(x = "Date",

y = "Approval Rating",

title = "Richard Nixon's Approval Rating over the Years",

subtitle = "Nixon was a relatively popular president as he withdrew troops from Vietnam and was even able

to get re-elected. As soon as he took responsibility for the Watergate though, there

continued to be a steep decline in approval ratings") +

annotate(geom="text", x=as.Date.character(c("1969-08-8", "1972-11-7", "1972-1-17", "1974-03-08", "1973-4-30")), y=c(40, 47, 40, 40, 65),

label=c('atop(bold("Announces Plan to"), bold("Leave Vietnam"))', 'bold("Wins Re-Election")', 'atop(bold("DNC Headquarters Is"), bold("Broken Into"))', 'atop(bold("Nixon Officially"), bold("Resigns"))', 'atop(bold("Nixon Takes Responsibility"), bold("For Watergate"))'), color="black", parse = TRUE) +

theme(plot.title = element_text(face="bold", size =14),

axis.title.x = element_text(face="bold", size = 12),

axis.title.y = element_text(face="bold", size = 12),

legend.position = "none")

nixon.plot

Figure 2 — Nixon’s approval rating was fairly stable until the watergate scandal finally took hold

How about George W. Bush’s ratings? This one is really like a rollercoaster thanks to 9/11!

bushjr.plot <- df2 %>%

filter(president == "BushJr") %>%

ggplot(aes(x = date, y = approval, color = "red")) +

geom_point(alpha=0.7, color = "red") +

geom_smooth(span = 0.5, alpha = 0.5, color = "red") +

geom_vline(xintercept = as.numeric(as.Date(c("2001-9-11", "2003-3-20", "2006-11-07", "2007-12-01"))), linetype= 4, color = "black", size=0.5) +

labs(x = "Date",

y = "Approval Rating",

title = "George W. Bush's Approval Rating over the Years",

subtitle = "Bush Jr. had an ever decreasing approval rating broken up by two jumps:

1) Right after Sept-11th and 2) When he declared war on Iraq",

color = "President") +

annotate(geom="text", x=as.Date.character(c("2001-9-11", "2003-3-20", "2006-11-07", "2007-12-01")), y=c(40, 80, 60, 50),

label=c('bold("Sept 11th Attack")', 'atop(bold("Iraq War"), bold("Declaration"))', 'atop(bold("2006 Mid-Term"), bold("Elections"))', 'atop(bold("Great Recession"), bold("Begins"))'), color="black", parse = TRUE) +

theme(plot.title = element_text(face="bold", size =14),

axis.title.x = element_text(face="bold", size = 12),

axis.title.y = element_text(face="bold", size = 12),

legend.position = "none")

bushjr.plot

Figure 3 — Bush’s tenure is marked by the 9/11 attacks and the Iraq war, both which saw spikes in his approval rating

Let’s see how to graph the two most recent presidents now, Obama and Trump. As you can see, these are much more consistent and less volatile than all others, with major events not changing approval ratings all that much, especially for Trump.

obama.plot <- df2 %>%

filter(president == "Obama") %>%

ggplot(aes(x = date, y = approval, color = "blue")) +

geom_point(alpha=0.7, color = "blue") +

geom_smooth(span = 0.5, alpha = 0.5, color = "blue") +

geom_vline(xintercept = as.numeric(as.Date(c("2010-3-20", "2011-5-2", "2012-11-07", "2015-03-2"))), linetype= 4, color = "black", size=0.5) +

labs(x = "Date",

y = "Approval Rating",

title = "Barack Obama's Approval Rating over the Years",

subtitle = "Obama's popularity peaked both times he was elected, showing his strong ability to campaign.

He also got a spike when Bin Laden was killed in 2011") +

annotate(geom="text", x=as.Date.character(c("2010-3-20", "2011-5-2", "2012-11-07", "2015-03-2")), y=c(70, 60, 65, 55),

label=c('bold("Passes ObamaCare")', 'atop(bold("Osama Bin Laden"), bold("Assasinated"))','bold("Wins Re-Election")', 'atop(bold("Clintons Email"), bold("Scandal"))'),

color="black", parse = TRUE) +

theme(plot.title = element_text(face="bold", size =14),

axis.title.x = element_text(face="bold", size = 12),

axis.title.y = element_text(face="bold", size = 12),

legend.position = "none")

obama.plot

Figure 4 — Obama rode his two campaigns to the top of the approval rating, and interestingly saw a rise near the end of his presidency

# Now time for Trump trump.plot <- df2 %>%

filter(president == "Trump") %>%

ggplot(aes(x = date, y = approval, color = "orange")) +

geom_point(alpha=0.7, color = "orange") +

geom_smooth(method = 'loess', span = 0.5, alpha = 0.5, color = "orange") +

geom_vline(xintercept = as.numeric(as.Date(c("2017-12-22", "2018-11-6", "2019-12-18", "2020-03-25", "2021-01-6"))), linetype= 4, color = "black", size=0.5) +

ylim(32, 50) +

labs(x = "Date",

y = "Approval Rating",

title = "Donald Trump's Approval Rating over the Years",

subtitle = "Trump's highest approval came at the beginning of the pandemic, and the lowest as he

incited the 2021 capital riots. With a 12 point gap between the two, his approval rating

was fairly stable no matter what happened") +

annotate(geom="text", x=as.Date.character(c("2017-12-22", "2018-11-6", "2019-12-18", "2020-03-25", "2020-11-20")), y=c(48, 45, 37, 47, 45),

label=c('atop(bold("Trump Tax Cuts"), bold("Signed Into Law"))', 'atop(bold("Democrats Win Back"), bold("The House"))', 'atop(bold("First Impeachment"), bold("Begins"))', 'atop(bold("COVID Pandemic"), bold("Arrives"))', 'atop(bold("Storming Of"), bold("The Capital"))'),

color="black", parse = TRUE) +

theme(plot.title = element_text(face="bold", size =14),

axis.title.x = element_text(face="bold", size = 12),

axis.title.y = element_text(face="bold", size = 12),

legend.position = "none")

trump.plot

Figure 5 — Trump’s approval is the most stable of all presidents. The graph only shows approval between the 30–50% range, demonstrating the lack of volatility

The beauty of these 4 plots is that you can actually understand why the dips and rises in approval ratings happened, linking the data to the story! This is so so so so so so so important for data scientists and analysts, especially in the business world where your boss wants to see one chart/ graphic to explain ten pages of analysis.

Thanks for reading and hope you learned something about storytelling, ggplot2 and using text in plots. While you can simply add this type of text overtop using PowerPoint or something, it becomes a powerful tool when you can automate it and figure out how to do it in your coding graphics in R .