我試圖使用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()'。我更新了答案。 –