我试图使用ggplot如何添加标签到ggplot片段?
dat <- data.frame(start <- c(-1.05113647, -0.63911585, -0.62791554),
end <- c(0.37491159, -0.13911585, -0.12791554),
order <- c("Sei whale", "Probeagle", "Northern fur seal"),
pos <- c(1, 2, 3))
ggplot(dat) +
geom_segment(aes(x=start, y=start, xend=end, yend=start), colour = "blue", size = 2) +
scale_y_reverse() +
xlab("PC1")+
ylab(" ")+
theme_linedraw() +
theme(panel.grid.minor = element_blank(), panel.grid.major = element_blank()) +
theme(aspect.ratio = 0.3) +
theme(legend.position="none") +
theme(axis.ticks = element_blank(), axis.text.y = element_blank())
我想知道如何将名字从“命令”,以各自细分市场增添标签添加到段我创建了一个曲线图。
使用直接标签 – akrun
谢谢@steven,这正是我所期待的。一个问题是,添加geom_dl x轴上的刻度线已经消失。任何方式让它回来? – Nomnoom
@Nomnoom哦,那不是因为'geom_dl()'。我犯了一个错误,在我之前的例子中使用'scale_x_discrete()'而不是'scale_x_continuous()'。我更新了答案。 –