是否要删除ggplot2中y轴上的增量标签?

问题描述 投票:0回答:1

我正在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

谢谢!

r ggplot2 axis-labels
1个回答
0
投票

一种简单的方法是将年份更改为因子,但是我不确定这是否是正确的方法。

ggplot(NULL,aes(sos,as.factor(year)))+

© www.soinside.com 2019 - 2024. All rights reserved.