annotation

Published by onesixx on

 

 

library(data.table)
set.seed(666)
DT <- data.table( A=rep(c("a","b","c"),each=2), B=c(1:3), C=sample(6), D=sample(6))
setkey(DT, A)

 

DT %>% ggplot(aes(A,B)) + geom_point()+ 
    annotate(geom='text', label="Top    right", x= Inf, y= Inf, hjust= 1.1, vjust= 2) +
    annotate(geom='text', label="Bottom right", x= Inf, y=-Inf, hjust= 1.1, vjust=-1) +
    annotate(geom='text', label="Bottom left" , x=-Inf, y=-Inf, hjust=-0.1, vjust=-1) +
    annotate(geom='text', label="Top    left" , x=-Inf, y= Inf, hjust=-0.1, vjust= 2)

 

 

—————-

   if (!is.null(env4$dtraceui)){ 
         p <- p + annotate(geom='text', label=env4$dtraceui , x =Inf , y = -Inf, hjust = 1, vjust = -1) 
    }

 

 

Categories: ggplot2

onesixx

Blog Owner

Leave a Reply

Your email address will not be published.