The goal is to draw a scatter plot and show the relationship between carbon emissions and global temperature.
ggplot(clean_climate_data, aes(x = carbon_emissions, y = temp_anomaly, color = year)) +geom_point(size =2.5, alpha =0.8) +geom_smooth(method ="lm", color ="red", linetype ="dashed", se =FALSE, size =0.8) +geom_text_repel(aes(label=ifelse(year %in%c(1900,1950,1975,2000,2010),as.character(year),"")),color="black" )+labs(title ="Global Temperature Anomaly vs. Carbon Emissions",subtitle ="Data covers aligned years (1880–2014)",x ="Global Carbon Emissions (Millions of Metric Tons)",y ="Temperature Anomaly (°C relative to 20th Century Mean)",color ="Year" ) +theme_minimal() +theme(plot.title =element_text(face ="bold", size =14),legend.position ="right" )
Warning: Using `size` aesthetic for lines was deprecated in ggplot2 3.4.0.
ℹ Please use `linewidth` instead.
`geom_smooth()` using formula = 'y ~ x'
Conclusions:
1) As global emissions keep increasing, the temperature anomaly accelerates upwards.
2) The time variable - The color shift from dark blue to light blue shows that this relationship tracks with industrial increase in the last 100 years.