是否有办法删除 ggplot2 中 y 轴上的增量标签?
Is there away to remove increment labels on the y axis in ggplot2?
我正在 ggplot2 中的散点图上绘制三年的数据,其中年份为 y 轴。轴正在缩放,因此刻度线标签为“2015.5、2016、2016.5 ……等”。我需要它们只是“2016 2017 2018”。我尝试使用 scale_y_discrete 函数。
这是我的代码
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")
这是当前的
scatterplot
谢谢!
一个简单的方法是改变年份作为因素,但我不确定这样做是否正确。
ggplot(NULL, aes(sos, as.factor(year))) +
您检查过年份变量是数字吗?如果这是数字那么我认为 Solorzanos 解决方案应该有效
我正在 ggplot2 中的散点图上绘制三年的数据,其中年份为 y 轴。轴正在缩放,因此刻度线标签为“2015.5、2016、2016.5 ……等”。我需要它们只是“2016 2017 2018”。我尝试使用 scale_y_discrete 函数。
这是我的代码
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")
这是当前的 scatterplot
谢谢!
一个简单的方法是改变年份作为因素,但我不确定这样做是否正确。
ggplot(NULL, aes(sos, as.factor(year))) +
您检查过年份变量是数字吗?如果这是数字那么我认为 Solorzanos 解决方案应该有效