我正在生成一个图,并试图找出如何抑制一个勾号标签(不是标记,而是标签)。
以下是一些示例代码:
x1 <- seq(0, 100, by = 1)
y1 <- runif(n = 100, min = 1, max = 10)
library(rando)
labe <- r_Letters(nchar = 1, n = 100)
test_dat <- as.data.frame(cbind(x1, y1, labe))
test_dat$x1 <- as.numeric(test_dat$x1)
test_dat$y1 <- as.numeric(test_dat$y1)
library(ggplot2)
library(ggrepel)
g <- ggplot(data = test_dat, aes(x = x1, y = y1))
g <- g + geom_line()
g <- g + geom_point()
g <- g + expand_limits(x = c(-10, 110), y = c(0, 10))
g <- g + scale_x_continuous(breaks = scales::pretty_breaks(n = 25))
g <- g + scale_y_continuous(breaks = scales::pretty_breaks(n = 5))
g <- g + geom_label_repel(data = test_dat, aes(x = x1, y = y1, label = labe),
size = 2.0, color = "blue", box.padding = unit(0.5, "lines"),
point.padding = unit(0, "lines"))
g
在我的真实数据集中,当我使用geom_label_reject来标记我的点(我真实数据的一个子集;在我的例子中我变得懒惰了)时,我需要扩展图的范围(因此,expand_limits)。所有的勾号都在我想要的地方,但最左边的那个(在我的例子中为-15)是不物理的,我想删除
就这一个。
我可以想出如何抑制所有的勾号和标签,但这不是我想要的——我想让勾号保持原样,但只需删除最左侧的标签。
有什么想法吗?