I am using plotly with Rshiny to create a scatter plot with text labels. Below is a reproducible example:
library(ggplot2)
library(plotly)
dat <- data.frame(LongExpressionValue = rnorm(1:100),
LongMethylationValue = rnorm(1:100),
LongCopyNumberValue = rnorm(1:100))
rownames(dat) <- paste0('n',seq(1:100))
# ggplot
p <- ggplot(data = dat, aes(x = LongExpressionValue, y = LongMethylationValue)) +
geom_point(size = 2) + geom_smooth(method = lm) +
geom_text(aes(label = rownames(dat)), vjust=-1.5, size = 3)
# ggplotly
ggplotly(p)
This creates a plot like:
How do I adjust my geom_text options so that the labels appear above and not overlapping the points? I do want to retain my ggplot code for it to be used across applications.
Thanks!