Replicating the graph

This graph can be found at https://ourworldindata.org/grapher/corporate-investment-in-artificial-intelligence-by-type?time=2020..latest

ggplot(investment_in_AI, aes(x = Year, y = Global_corporate_investment_in_AI, fill = Entity)) +
  geom_bar(stat = "identity") +
  scale_fill_manual(values = c(
    "Merger/acquisition" = "#C2651E",
    "Private investment" = "#677D3A",  
    "Public offering" = "#99334A",   
    "Minority stake" = "#3C6289" 
  )) +
  labs(
    title = "Annual global corporate investment in artificial intelligence, by type",  
    subtitle = "This data is expressed in US dollars, adjusted for inflation.",
    caption = "Data source: Quid via AI Index (2024); U.S. Bureau of Labor Statistics (2024)\nNote: Data is expressed in constant 2021 US$.\nInflation adjustment is based on the US Consumer Price Index (CPI).\nOurWorldinData.org/artificial-intelligence | CC BY",
    fill = "Entity",
    x = "",
    y = ""
  ) +
  scale_x_continuous(breaks = c(2013, 2014, 2015, 2016, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023)) +
  scale_y_continuous(
    breaks = seq(0, 300000000000, by = 50000000000),
    labels = c("$0 billion", "$50 billion", "$100 billion", "$150 billion", "$200 billion", "$250 billion", "$300 billion")
  ) +
  theme(
    legend.position = c(.95, .85),
    legend.background = element_blank(),
    panel.background = element_rect(fill = "white"),
    panel.grid.major.y = element_line(color = "gray", linetype = "dashed"), 
    panel.grid.major.x = element_blank(), 
    panel.grid.minor.x = element_blank(),
    legend.key.size = unit(0.3, "cm"),           
    legend.key.height = unit(0.2, "cm"),     
    legend.key.width = unit(0.3, "cm")
  ) 

Redesigning the graph

I enhanced the visualization by adding facets based on Entities to create distinct plots, rotating the x-axis labels for improved readability, and using colorblind-friendly fill colors.
Additionally, I refined the y-axis labels for a more focused data representation and adjusted the bar width for better visual balance.
To highlight trends over time, I added lines depicting investment changes across years.
Lastly, I introduced a graph for Minority Stake and Public Offering, refining the y-axis scale.

main <- ggplot(investment_in_AI, aes(x = Year, y = Global_corporate_investment_in_AI, fill = Entity)) +
  geom_bar(stat = "identity", width = 0.78) +
  geom_line(aes(group = Entity, color = Entity)) +
  scale_fill_manual(values = viridis(4)) +
  labs(
    title = "Annual global corporate investment in artificial intelligence",  
    subtitle = "This data is expressed in US dollars, adjusted for inflation.",
    fill = "Entity",
    x = "",
    y = ""
  ) +
  scale_x_continuous(breaks = c(2013, 2014, 2015, 2016, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023)) +
  scale_y_continuous(
    breaks = seq(0, 150000000000, by = 50000000000),
    labels = c("$0 billion", "$50 billion", "$100 billion", "$150 billion")
  ) +
  theme(
    legend.background = element_blank(),
    panel.background = element_rect(fill = "white"),
    panel.grid.major.y = element_line(color = "gray", linetype = "dashed"), 
    panel.grid.major.x = element_blank(), 
    panel.grid.minor.x = element_blank(),
    legend.key.size = unit(0.3, "cm"),           
    legend.key.height = unit(0.2, "cm"),     
    legend.key.width = unit(0.3, "cm"),
    axis.text.y = element_text(size = 10), 
    axis.text.x = element_text(angle = 45, hjust = 1) 
  ) +
  facet_wrap(~ Entity) 

zoom <- investment_in_AI %>%
  filter(Entity == "Minority stake" | Entity == "Public offering") %>%
  ggplot(aes(x = Year, y = Global_corporate_investment_in_AI, fill = Entity)) +
  geom_bar(stat = "identity", width = 0.78) +
  geom_line(aes(group = Entity, color = Entity)) +
  scale_fill_manual(values = viridis(2)) +
  labs(
    title = "A closer look at AI investment in Minority stake and Public offering",  
    caption = "Data source: Quid via AI Index (2024); U.S. Bureau of Labor Statistics (2024)\nNote: Data is expressed in constant 2021 US$.",
    fill = "Entity",
    x = "",
    y = ""
  ) +
  scale_x_continuous(breaks = c(2013, 2014, 2015, 2016, 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023)) +
  scale_y_continuous(
    transform = "log2",
    breaks = c(128,65000,33000000,1700000000),
    labels = c("$128", "$65 thousand", "$33 million", "$17 billion")
  ) +
  theme(
    legend.background = element_blank(),
    panel.background = element_rect(fill = "white"),
    panel.grid.major.y = element_line(color = "gray", linetype = "dashed"), 
    panel.grid.major.x = element_blank(), 
    panel.grid.minor.x = element_blank(),
    legend.key.size = unit(0.3, "cm"),           
    legend.key.height = unit(0.2, "cm"),     
    legend.key.width = unit(0.3, "cm"),
    axis.text.y = element_text(size = 10), 
    axis.text.x = element_text(angle = 45, hjust = 1) 
  ) +
  facet_wrap(~ Entity) 

main / zoom + plot_layout(heights = c(4, 1.5))

Summary

The original plot I found online had a clean background with only the most useful grid lines, along with clear titles, subtitles, and labels for the x and y axes. However, I found it hard to see the trends in how investments by each entity grew over time. To address this, I added facets to create separate plots for each entity, making the trends more apparent. I also noticed that the original colors were not colorblind-friendly, so I switched to a colorblind-friendly palette. Additionally, with two plots displayed in a single row, I rotated the x-axis labels to avoid overlap and improve readability. Finally, I observed that the investment trends for Minority Stake and Public Offering were difficult to track due to their relatively lower AI investment compared to the other two entities. To address this, I used patchwork to create a separate graph with a log2 scale, providing a clearer visualization of investment trends in these two entities over the years.