library(nycflights13)
## Warning: package 'nycflights13' was built under R version 4.1.3
library(ggplot2)
library(dplyr)
## 
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
## 
##     filter, lag
## The following objects are masked from 'package:base':
## 
##     intersect, setdiff, setequal, union
tempdata <- weather %>% 
    group_by(month, day) %>%
    summarise(temp = mean(temp, na.rm = TRUE))
## `summarise()` has grouped output by 'month'. You can override using the `.groups` argument.
head(tempdata)
## # A tibble: 6 x 3
## # Groups:   month [1]
##   month   day  temp
##   <int> <int> <dbl>
## 1     1     1  37.0
## 2     1     2  28.7
## 3     1     3  30.0
## 4     1     4  34.9
## 5     1     5  37.2
## 6     1     6  40.1
meanMonth <- tempdata %>%
    group_by(month) %>%
    summarise(temp = mean(temp, na.rm = TRUE))
ggplot(tempdata, aes(day, temp)) +
    geom_hline(data = meanMonth, aes(yintercept = temp),
               color = "purple") +
    geom_line(color=  "blue") +
    facet_grid(~ month, switch = "x") +
    labs(x = "Month",
         y = "Temperature") +
  theme(plot.title = element_text(size = 14, vjust = 0, hjust = 0),
  
  #axis.text.x = element_text(size=14, color = "#6d6d6d"),
  axis.text.y = element_text(size = 12, color = "#6d6d6d",hjust = 1),
  axis.text.x =element_blank(),
  
  axis.title.y= element_text(size = 12, color = "#6d6d6d",hjust = 1),
  axis.title.x= element_text(size = 12, color = "#6d6d6d"),
  
  axis.line.x= element_line(color="#a9a9a9", size = 0.75),
  axis.line.y= element_line(color="#a9a9a9", size = 0.75),
  
  axis.ticks.y = element_blank(),
  axis.ticks.x = element_blank(),
  panel.grid.major = element_blank(),
  panel.grid.minor = element_blank(),
  panel.background = element_blank())