I am plotting three years of data on a scatterplot in ggplot2, with years as the y-axis. The axis is scaling so that the tick mark labels are "2015.5, 2016, 2016.5 … etc." and I need them to just be "2016 2017 2018". I have tried to use the scale_y_discrete function.
Here is my code
x <- (plot <- ggplot(NULL, aes(sos, year)) +
geom_jitter(data = epic, aes(col = "EPIC")) +
geom_jitter(data = landsat, aes(col = "Landsat")) +
geom_jitter(data = pheno, aes(col = "PhenoCam")))
x + labs(title = "Start of Season Comparison",
x = "DOY",
y = "Year")
and here is the current scatterplot
Thank you!
scale_y_discrete
? – Edwardscale_y_continuous
and setting thebreaks
argument – Jonathan V. Solórzanoscale_y_discrete
it removes the y-label entirely. I added this code to the end of the script abovescale_y_discrete(breaks=c("2016", "2017", "2018"), labels=c("2016", "2017", "2018"))
and also tried it without breaks. – Maridee Weberscale_y_continuous
and setting the breaks argument gives me the error: "Error in r[i1] - r[-length(r):-(length(r) - lag + 1L)] : non-numeric argument to binary operator". Perhaps I am setting the breaks wrong? I am a new programmer...here is what I usedscale_y_continuous(breaks=c("2016", "2017", "2018"))
– Maridee Weberbreaks = c(2016, 2017, 2018)
– Jonathan V. Solórzano