Hi, I would like to generate a temperature anomalies graph with a trend line which looks almost like this:
This is my reprex:
library(ggplot2)
library(lubridate)
library(tidyverse)
df <- data.frame(stringsAsFactors = FALSE,
Date = c(1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993,
1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017),
Temp = c(-0.2, -0.1, -0.2, -0.7, -0.3, -0.4, -0.7, -0.8, -0.8, -0.2, 0.2, -0.4, 0.1,
-0.1, 0.2, -0.1, 0.4, 0.5, 1.0, 0.2, 0.2, 0.2, 0.1, -0.6, 0.6, 0.6,
0.2, 0.2, 0.5, 0.2, 0.3, 0.3, 0.2, 0.4, 0.0, 0.6, 0.5))
df %>%
mutate(Date = dmy(paste("01-01-", Date))) %>%
ggplot(aes(x = Date, y = Temp)) +
geom_line() + geom_area(colour = "red",size = 1)+theme_bw()+
scale_x_date(date_labels = "%Y",
date_breaks = "1 year",
minor_breaks = "1 year") +
theme_minimal() +
theme(axis.text.x = element_text(angle=45, hjust=1, vjust = 1))
I have the following graph:
I need some help with this. Thanks






