<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Data Viz on Laminar Insight</title>
    <link>https://laminarinsight.com/tags/data-viz/</link>
    <description>Recent content in Data Viz on Laminar Insight</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Mon, 15 Feb 2021 00:00:00 +0000</lastBuildDate>
    
        <atom:link href="https://laminarinsight.com/tags/data-viz/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Yet One More Plot to Show US&#39;s Race Inequality!</title>
      <link>https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/</link>
      <pubDate>Mon, 15 Feb 2021 00:00:00 +0000</pubDate>
      
      <guid>https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/</guid>
      <description>
&lt;script src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/header-attrs/header-attrs.js&#34;&gt;&lt;/script&gt;
&lt;script src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/kePrint/kePrint.js&#34;&gt;&lt;/script&gt;
&lt;link href=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/lightable/lightable.css&#34; rel=&#34;stylesheet&#34; /&gt;

&lt;div id=&#34;TOC&#34;&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#background&#34;&gt;Background&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#data&#34;&gt;Data&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#making-an-animated-plot-one-plot-at-a-time&#34;&gt;Making an Animated Plot &lt;small&gt;One plot at a time&lt;/small&gt;&lt;/a&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;#a-static-line-plot&#34;&gt;A static line plot&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#a-plot-with-additional-insight&#34;&gt;A plot with additional insight&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#making-it-visually-appealing&#34;&gt;Making it visually appealing&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#lets-make-the-plot-move&#34;&gt;Let’s make the plot move!&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;#final-visual&#34;&gt;Final Visual&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

&lt;div id=&#34;background&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Background&lt;/h2&gt;
&lt;p&gt;Last week’s &lt;a href=&#34;https://github.com/rfordatascience/tidytuesday/&#34;&gt;TidyTuesday&lt;/a&gt; was all about wealth inequality in the United States. Since I work for a university, I have seen how students’ success varies among races. Looking back at their socio-economic backgrounds makes it quite obvious that wealth, hidden behind their races, plays its role in their success. That makes the student debt data an interesting case for me to look into.&lt;/p&gt;
&lt;p&gt;So here’s the outcome of that: an animated graph that will show you how America’s races have historically been different in their student debt accumulation and how it’s getting worse increasingly.&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;data&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Data&lt;/h2&gt;
&lt;p&gt;As said earlier, the data comes from TidyTuesday. Here’s the &lt;a href=&#34;https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-02-09/readme.md&#34;&gt;detail&lt;/a&gt; about the data.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;# libraries
# devtools::install_github(&amp;quot;thomasp85/transformr&amp;quot;)
library(ggplot2)
library(tidyverse)
library(ggtext)
library(gganimate) 
library(extrafont)
library(knitr)
library(kableExtra)

# data
student_debt &amp;lt;- readr::read_csv(&amp;#39;https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2021/2021-02-09/student_debt.csv&amp;#39;)

# glimpse of the data
student_debt %&amp;gt;%
  head(5) %&amp;gt;%
  knitr::kable(caption = &amp;quot;Top 5 lines of the data&amp;quot;) %&amp;gt;%
  kable_classic(full_width = F, html_font = &amp;quot;Cambria&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;table class=&#34; lightable-classic&#34; style=&#34;font-family: Cambria; width: auto !important; margin-left: auto; margin-right: auto;&#34;&gt;
&lt;caption&gt;
(#tab:library_&amp;amp;_data)Top 5 lines of the data
&lt;/caption&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
year
&lt;/th&gt;
&lt;th style=&#34;text-align:left;&#34;&gt;
race
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
loan_debt
&lt;/th&gt;
&lt;th style=&#34;text-align:right;&#34;&gt;
loan_debt_pct
&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2016
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
White
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
11108.410
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
0.3367511
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2016
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Black
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
14224.770
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
0.4183588
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2016
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Hispanic
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
7493.999
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
0.2189689
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2013
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
White
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
8363.605
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
0.2845555
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
2013
&lt;/td&gt;
&lt;td style=&#34;text-align:left;&#34;&gt;
Black
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
10302.660
&lt;/td&gt;
&lt;td style=&#34;text-align:right;&#34;&gt;
0.4122773
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;One great thing about this data is it’s already cleaned! To know more about the cleaning steps, feel free to go to the documentation &lt;a href=&#34;https://github.com/rfordatascience/tidytuesday/blob/master/data/2021/2021-02-09/readme.md&#34;&gt;here&lt;/a&gt;. Here’s a short description of the data:&lt;/p&gt;
&lt;table&gt;
&lt;caption&gt;Data Description&lt;/caption&gt;
&lt;thead&gt;
&lt;tr class=&#34;header&#34;&gt;
&lt;th&gt;variable&lt;/th&gt;
&lt;th&gt;class&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;year&lt;/td&gt;
&lt;td&gt;double&lt;/td&gt;
&lt;td&gt;Year of measure&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;race&lt;/td&gt;
&lt;td&gt;character&lt;/td&gt;
&lt;td&gt;Racial group&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;odd&#34;&gt;
&lt;td&gt;loan_debt&lt;/td&gt;
&lt;td&gt;double&lt;/td&gt;
&lt;td&gt;Loan debt&lt;/td&gt;
&lt;/tr&gt;
&lt;tr class=&#34;even&#34;&gt;
&lt;td&gt;loan_debt_pct&lt;/td&gt;
&lt;td&gt;double&lt;/td&gt;
&lt;td&gt;Share of families with student loan debt&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;div id=&#34;making-an-animated-plot-one-plot-at-a-time&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Making an Animated Plot &lt;small&gt;One plot at a time&lt;/small&gt;&lt;/h2&gt;
&lt;p&gt;I will use &lt;code&gt;gganimate&lt;/code&gt; package to plot the plot. Before using &lt;code&gt;gganimate&lt;/code&gt; we will first make a plot that we like using &lt;code&gt;ggplot&lt;/code&gt;, the mighty data viz package from R. In the following code blocks and subsequent paragraphs I will walk you through step by step on how to do that.&lt;/p&gt;
&lt;div id=&#34;a-static-line-plot&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;A static line plot&lt;/h3&gt;
&lt;p&gt;Let’s start with a very simple line graph that will show the yearly trend of student debt in different races. This plot will work as the skeleton on top of which we’ll keep adding new layers and additional bells and whistles to make it nicer and meaningful.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
student_debt %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race)
  ) +
    geom_line()&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/plot1-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Some immediate improvement points are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Adding a title and labeling the axis,&lt;/li&gt;
&lt;li&gt;Separating lines with distinct colors,&lt;/li&gt;
&lt;li&gt;The default values on the x and y axes are not very meaningful. Breaking down the x and y axes values might make them more meaningful.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;student_debt %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race)
  ) +
  geom_line(aes(color = race)) +
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  labs(title=&amp;quot;Average Family Student Loan&amp;quot;,
         x = NULL, color = NULL, y = &amp;quot;Average Loan Debt&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/plot2-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Quite an improvement!&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;a-plot-with-additional-insight&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;A plot with additional insight&lt;/h3&gt;
&lt;p&gt;We have one yet unused but very crucial piece of data available to us - &lt;code&gt;loan_debt_pct&lt;/code&gt;: percent of families with student loan debt. We can add that insight to our plot by using the newly added points!&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;
student_debt %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race)
  ) +
  
  geom_line(aes(color = race)) +
  
  geom_point(aes(
    size = loan_debt_pct)
             ) +
  
  
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  labs(title=&amp;quot;Average Family Student Loan&amp;quot;,
         color = NULL,
         x = NULL, y = &amp;quot;Average Loan Debt&amp;quot;,
         subtitle =&amp;quot;Point sizes represent % of families with student loans&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/plot3-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;p&gt;Now let’s make some more improvements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The color of the points on different lines represents the corresponding race. Let’s make that clear by having the same color as the lines,&lt;/li&gt;
&lt;li&gt;While doing that, let’s also change the colors from auto-generated &lt;code&gt;ggplot&lt;/code&gt; colors to our custom colors (e.g. black for Blacks, white for Whites, and brown for Hispanics),&lt;/li&gt;
&lt;li&gt;The sequence of the legends for the race variable is also not aligned with the sequence of the lines on the graph. Let’s rearrange the legends too,&lt;/li&gt;
&lt;li&gt;The size legend also needs some reworking. Since it’s tough to measure the size of circles just from a view, let’s take those legends out and rather call out actual percents on the plot.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;student_debt %&amp;gt;%
  mutate(race = fct_relevel(race, &amp;quot;Black&amp;quot;, &amp;quot;White&amp;quot;, &amp;quot;Hispanic&amp;quot;)) %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race,
        color = race)
  ) +
  
  geom_line(aes()) +
  
  geom_point(aes(
    size = loan_debt_pct),
    show.legend = FALSE) +
  
  geom_text(aes(
    label = paste0(round(loan_debt_pct * 100, 2), &amp;quot;%&amp;quot;)
  ), 
  show.legend = FALSE,
  hjust = 1, vjust = 0) + 
  
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  scale_color_manual(values = c(&amp;quot;White&amp;quot; = &amp;quot;#ffffff&amp;quot;, &amp;quot;Black&amp;quot; = &amp;quot;#787575&amp;quot;, &amp;quot;Hispanic&amp;quot; = &amp;quot;#f5bf42&amp;quot;)) + 
                                
  labs(title=&amp;quot;Average Family Student Loan&amp;quot;,
         color = NULL,
         x = NULL, y = &amp;quot;Average Loan Debt&amp;quot;,
         subtitle =&amp;quot;Point sizes represent % of families with student loans&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/plot4-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;making-it-visually-appealing&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Making it visually appealing&lt;/h3&gt;
&lt;p&gt;Our chart is almost ready; content-wise. But visually it can be much better. The colors are not blending well on the default ggplot background. To make it better I modified &lt;code&gt;theme_dark()&lt;/code&gt; from ggplot and created a customized these for this plot. Since this tutorial is not about ggplot theme, I’ll not discuss much on the theme here. That will be part of another tutorial in the future. But in case you are interested to play with ggplot theme here’s a good &lt;a href=&#34;https://rpubs.com/mclaire19/ggplot2-custom-themes&#34;&gt;tutorial&lt;/a&gt; that I recommend.&lt;/p&gt;
&lt;p&gt;In the iteration of the plot we’ll make the following changes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Change the default theme to a darker theme,&lt;/li&gt;
&lt;li&gt;Adjust line style to match the dark theme,&lt;/li&gt;
&lt;li&gt;To make the percent point texts less cluttered, let’s also make them appear only for the last three years.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;student_debt %&amp;gt;%
  mutate(race = fct_relevel(race, &amp;quot;Black&amp;quot;, &amp;quot;White&amp;quot;, &amp;quot;Hispanic&amp;quot;)) %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race,
        color = race)
  ) +
  
  geom_line(aes(),
            size = 1,
            linetype = &amp;quot;dashed&amp;quot;) +
  
  geom_point(aes(
    size = loan_debt_pct),
    show.legend = FALSE) +
  
  geom_text(aes(
    label = ifelse(year &amp;gt;= 2010, 
                   paste0(round(loan_debt_pct * 100), &amp;quot;%&amp;quot;),
                   &amp;quot;&amp;quot;)
    ), 
  show.legend = FALSE,
  size = 4,
  hjust = 1, vjust = 0) + 
  
  theme_race() + 
  
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  scale_color_manual(values = c(&amp;quot;White&amp;quot; = &amp;quot;#ffffff&amp;quot;, &amp;quot;Black&amp;quot; = &amp;quot;#787575&amp;quot;, &amp;quot;Hispanic&amp;quot; = &amp;quot;#f5bf42&amp;quot;)) + 
                                
  labs(title=&amp;quot;Average Family Student Loan&amp;quot;,
         color = NULL,
         x = NULL, y = &amp;quot;Average Loan Debt&amp;quot;,
         subtitle =&amp;quot;Point sizes represent % of families with student loans&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/plot5-1.png&#34; width=&#34;672&#34; /&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;div id=&#34;lets-make-the-plot-move&#34; class=&#34;section level3&#34;&gt;
&lt;h3&gt;Let’s make the plot move!&lt;/h3&gt;
&lt;p&gt;I think we are in a good enough state to move on to making the plot animated. Animating the graph is pretty easy using &lt;code&gt;gganimate&lt;/code&gt;. We will add ~2 lines of codes to make it.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;student_debt %&amp;gt;%
  mutate(race = fct_relevel(race, &amp;quot;Black&amp;quot;, &amp;quot;White&amp;quot;, &amp;quot;Hispanic&amp;quot;)) %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        group = race,
        color = race)
  ) +
  
  geom_line(aes(),
            size = 1,
            linetype = &amp;quot;dashed&amp;quot;) +
  
  geom_point(aes(
    size = loan_debt_pct),
    show.legend = FALSE) +
  
  geom_text(aes(
    label = ifelse(year &amp;gt;= 2010, 
                   paste0(round(loan_debt_pct * 100), &amp;quot;%&amp;quot;),
                   &amp;quot;&amp;quot;)
    ), 
  show.legend = FALSE,
  size = 4,
  hjust = 1, vjust = 0) + 
  
  theme_race() + 
  
  transition_reveal(year) +
  
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  scale_color_manual(values = c(&amp;quot;White&amp;quot; = &amp;quot;#ffffff&amp;quot;, &amp;quot;Black&amp;quot; = &amp;quot;#787575&amp;quot;, &amp;quot;Hispanic&amp;quot; = &amp;quot;#f5bf42&amp;quot;)) + 
                                
  labs(title=&amp;quot;Average Family Student Loan&amp;quot;,
         color = NULL,
         x = NULL, y = &amp;quot;Average Loan Debt&amp;quot;,
         subtitle =&amp;quot;Point sizes represent % of families with student loans&amp;quot;)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/animation1-1.gif&#34; /&gt;&lt;!-- --&gt;&lt;/p&gt;
&lt;p&gt;In our animation, two areas need improvements to make the visual more reader-friendly:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The points and texts are disappearing as soon as the new data point is populated. Let’s make them stay,&lt;/li&gt;
&lt;li&gt;The animation is running and recycling too fast. Let’s slow it a bit and make it take a longer pause after it’s finished one cycle,&lt;/li&gt;
&lt;li&gt;Let’s add a counter on top of the chart that will show the current year as the plot moves,&lt;/li&gt;
&lt;li&gt;And as a final brush up, let’s also add some more clarity for the labels and add a source credit.&lt;/li&gt;
&lt;/ul&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;student_debt %&amp;gt;%
  mutate(race = fct_relevel(race, &amp;quot;Black&amp;quot;, &amp;quot;White&amp;quot;, &amp;quot;Hispanic&amp;quot;)) %&amp;gt;%
  ggplot(
    aes(x = year, 
        y=loan_debt, 
        color = race)
  ) +
  
  geom_line(aes(),
            size = 1,
            linetype = &amp;quot;dashed&amp;quot;) +
  
  geom_point(aes(
    size = loan_debt_pct,
    group = seq_along(year)),
    show.legend = FALSE) +
  
  geom_text(aes(
    label = ifelse(year &amp;gt;= 2010, 
                   paste0(round(loan_debt_pct * 100), &amp;quot;%&amp;quot;),
                   &amp;quot;&amp;quot;),
    group = seq_along(year)
    ), 
  show.legend = FALSE,
  size = 4,
  hjust = 1, vjust = 0) + 
  
  theme_race() + 
  
  transition_reveal(as.integer(year)) + # as.integer(year) makes the year showing in subtitle as integer.
  
  scale_x_continuous(breaks = seq(1989, 2016, 3)) + 
    scale_y_continuous(breaks = seq(500, 15000, 1500), 
                       labels = scales::dollar) +
  scale_color_manual(values = c(&amp;quot;White&amp;quot; = &amp;quot;#ffffff&amp;quot;, &amp;quot;Black&amp;quot; = &amp;quot;#787575&amp;quot;, &amp;quot;Hispanic&amp;quot; = &amp;quot;#f5bf42&amp;quot;)) + 
                                
  labs(title=&amp;quot;Average Student Loan Taken by the US Families&amp;quot;,
       x = NULL, color = NULL,
       y = &amp;quot;Average Loan Debt \n($ normalized to 2016 dollars)&amp;quot;, 
       caption = &amp;quot;Source: Urban Institute, and the US Census,\n2017 | Arafath Hossain&amp;quot;,
       subtitle =&amp;quot;Point sizes represent % of families with student loans \nYear: {frame_along}&amp;quot;) -&amp;gt; plot&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div id=&#34;final-visual&#34; class=&#34;section level2&#34;&gt;
&lt;h2&gt;Final Visual&lt;/h2&gt;
&lt;p&gt;So, after all those updates, here’s our final visual that takes us on a journey to one perpetuating aspect of the racial inequality in the US.&lt;/p&gt;
&lt;pre class=&#34;r&#34;&gt;&lt;code&gt;plot %&amp;gt;% 
  animate(fps = 8, end_pause = 12, height = 6, width = 10, units = &amp;quot;in&amp;quot;, res = 150)&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;img src=&#34;https://laminarinsight.com/post/2021-02-13-the-race-to-inequality-in-the-us/index_files/figure-html/final_plot-1.gif&#34; /&gt;&lt;!-- --&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;p&gt;Plot animation can be a nice tool to convey your message when it comes about calling out a specific trend over time. I had fun working on this plot and hope you find it fun and useful too in your projects!&lt;/p&gt;
&lt;/div&gt;
</description>
    </item>
    
  </channel>
</rss>
