[R] variable in annotation, ggplot2
Troels Ring
tr|ng @end|ng |rom gvdnet@dk
Mon Dec 16 15:55:29 CET 2019
Hi friends - I have a simple problem of inserting values in label of a
ggplot2. I have a vector V with two values and want to show them in the
plot.
Here is what I tried - at most get the first entry "28".
R version 3.6.1 (2019-07-05)
Windows 10
BW
Troels
library(ggplot2)
x <- 1:5
y <- x^2
V <- c(28,14)
df <- data.frame(x=x,y=y)
ggplot(df,aes(x=x,y=y))+geom_line()+
annotate("text",x=3,y=20,label=bquote(V ==.(as.vector(V))))
ggplot(df,aes(x=x,y=y))+geom_line()+
annotate("text",x=3,y=20,label=expression(paste("V is ",V)))
ggplot(df,aes(x=x,y=y))+geom_line()+
annotate("text",x=3,y=20,label=bquote(V ==.(V)))
This email has been scanned by BullGuard antivirus protection.
For more info visit www.bullguard.com
<http://www.bullguard.com/tracking.aspx?affiliate=bullguard&buyaffiliate=smt
p&url=/>
[[alternative HTML version deleted]]
More information about the R-help
mailing list