Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Load libraries
library(tidyverse)
library(lubridate)
library(reshape2)
library(MBA)
library(mgcv)
# Load and screen data
# For ease I am only using monthly means
# and depth values rounded to 0.1 metres
ctd <- read_csv("../data/ctd.csv") %>%
mutate(depth = -depth) %>% # Correct for plotting
filter(site == 1) %>%
select(date, depth, temperature) %>%
rename(temp = temperature) #%>%
### Uncomment out the following lines to reduce the data resolution
# mutate(date = round_date(date, unit = "month")) %>%
# mutate(depth = round(depth, 1)) %>%
# group_by(date, depth) %>%
# summarise(temp = round(mean(temp, na.rm = TRUE),1))
###
# Manually extracted hexidecimal ODV colour palette
ODV_colours <- c("#feb483", "#d31f2a", "#ffc000", "#27ab19", "#0db5e6", "#7139fe", "#d16cfa")
# Create quick scatterplot
ggplot(data = ctd, aes(x = date, y = depth)) +
geom_point(aes(colour = temp)) +
scale_colour_gradientn(colours = rev(ODV_colours)) +
labs(y = "depth (m)", x = NULL, colour = "temp. (°C)")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment