ggplot(greenhouse_gases1, aes(x=year, y=gas, fill =log10(concentration))) +scale_x_continuous(expand =c(0, 0)) +scale_fill_gradientn(colors =brewer.pal(9, "Oranges"), trans ="sqrt") +geom_tile(color ="grey20") +theme_bw() +labs(title ="Greenhouse Gas Concentrations (1400-2000)", fill ="Concentration", x ="Year", y ="Gas") +theme(strip.background =element_blank(), strip.text.x =element_blank(), strip.text.y =element_blank())
The graph fails to highlight a lot of variation of CO2 and N2O because how large the vales scale for CH4 concentration.
Scaling the Gases to Show Variation
greenhouse_gases_scaled <- greenhouse_gases1 |>group_by(gas) |>mutate(concentration_scaled = (concentration -min(concentration)) / (max(concentration) -min(concentration)))#min becomes 0, max becomes 1 to show variation between min number and max
Graph 2
ggplot(greenhouse_gases_scaled, aes(x = year, y = gas, fill = concentration_scaled)) +geom_tile(color ="grey20") +scale_x_continuous(expand = (0)) +scale_fill_gradientn(colors =brewer.pal(9, "Oranges")) +geom_vline(xintercept=1870, col ="blue", size =1.5) +theme_bw() +labs(x ="Year",y ="Gas",fill ="Scaled Concentration",title ="Greenhouse Gas Concentrations (Normalized per Gas)")
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
Now the second graph shows the normalized variation of each gas, highlighting how quickly concentrations increased from their minimum in 1400 to their maximum in 2000. Rather than just showing absolute concentration levels, this graph emphasizes the relative rate of change for each gas, making the trends for CO₂ and N₂O more visible despite CH₄’s much larger scale. I also added a vertical line at 1870 to mark the Second Industrial Revolution, which may explain the sharp acceleration in gas concentrations. Together, the two graphs provide complementary insights: the first shows the absolute concentrations, while the second highlights the rapid increase in each greenhouse gas over time.