簡體   English   中英

如何使用注釋在ggplot2中繪制箭頭

[英]how to draw arrow in ggplot2 with annotation

我正在創建一個ggplot圖表,我需要在其中添加一些注釋。 我可以這樣做,但文本並沒有真正指出我喜歡注釋的日期。 有沒有辦法在axix中繪制箭頭,我喜歡創建注釋。

我有這個:

   ggplot(df, aes(Date, CPU)) + geom_point() + 
       annotate("text", x = as.POSIXct(c("2013-03-11 23:00:00")), 
                y = 90, label = "problem 1", angle=90, size=5, 
                colour='black', face="bold")

所以任何人都可能有相同的問題或疑問,這就是我所做的:

library(ggplot2)
library(grid)

ggplot(df, aes(Date, CPU)) + geom_point() + 
       annotate("text", x = as.POSIXct(c("2013-03-11 23:00:00")), 
                y = 90, label = "problem 1", angle=90, size=5, 
                colour='black', face="bold")
             +    geom_segment(aes(x = as.POSIXct(c("2013-03-11 09:00:00")), y = -30, xend = as.POSIXct(c("2013-03-11 09:00:00")), yend = 0), colour='#CC00FF', size=1,arrow = arrow(length = unit(0.5, "cm")))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM