[英]how to add a long directional arrow after the text in xlab ggplot2?
我想使用 ggplot2 在 xlab 中的文本后添加一個箭頭。 這是下面的代碼示例,我嘗試在其中添加虛線和符號,但它不是很美觀。
ggplot(data=Q2, aes(x=month, y=dataQ)) +xlab("Mois ------------------------------------------->") + ylab("Pr(mm)") +geom_bar(stat="identity", position = "dodge") + scale_x_discrete(limits=c("JAN", "FEB","MAR","APR","MAY","JUN","JUL","AUG","SEP","OCT","NOV","DEC"))+theme(plot.title = element_text(color="black", size=14, face="bold.italic"),axis.line = element_line(colour = "black", size = 1, linetype = "solid"),
axis.text.x = element_text(face="bold", color=" black",size=11, angle=0),axis.text.y = element_text(face="bold", color="black",size=11, angle=90),axis.title.x = element_text(color="black", size=14, face="bold"),
axis.title.y = element_text(color="black", size=14, face="bold")
)
您可以使用annotate
和clip = "off"
,如下所示:
library(ggplot2)
ggplot() +
coord_cartesian(ylim = c(0, 1), xlim = c(0, 1), clip="off") +
xlab("x label") +
ylab("y label") +
annotate("segment",
x = 0.6, xend = 0.9, y = -0.11, yend = -0.11,
arrow=arrow(length=unit(0.3, "cm")))
由reprex 包(v0.3.0) 創建於 2020-01-23
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.