The following code plots the points, not the string "Ocean"
but does more. It creates a new variable n
counting the repeats of O2_Conc
by year and ocean and treats the years as dates.
library(ggplot2)
library(dplyr)
df %>%
group_by(Year, Ocean) %>%
mutate(n = n()) %>%
mutate(Year = as.Date(paste(Year, "01", "01", sep = "-"))) %>%
ggplot(aes(Year, O2_Conc, color = Ocean)) +
geom_point(aes(size = n), alpha = 0.5, show.legend = FALSE) +
scale_x_date(date_breaks = "year", date_labels = "%Y")
Data
df <- read.table(text = "
Year Ocean O2_Conc
1 2010. Reference 0.000237
2 2010. Pacific 0.000165
3 2010. Southern 0.000165
4 2012. Reference 0.000237
5 2012. Pacific 0.000165
6 2012. Southern 0.000165
7 2012. Reference 0.000237
8 2012. Pacific 0.000165
9 2012. Southern 0.000165
", header = TRUE)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…