I have an R shiny application and on one page I have a scatter plot with about 100 markers. My goal is to add a label to each marker as explained here https://plotly.com/r/text-and-annotations/ It kind of words but the problem is that the text of each marker overlaps most of the time with text of other markers. After some research, I learned there are packages like ggrepel https://ggrepel.slowkow.com/articles/examples.html that help fix this problem. However, if I try to eventually reconvert the ggplot to plotly the text labels disappear. I will show you an example:
df <- data.frame(xvals = rnorm(1:100), yvals = rnorm(1:100), label_var = paste0("label_", as.character(round(rnorm(1:100),3))))
p <- ggplot(df, aes(xvals, yvals, label = label_var)) + geom_point(color = "red")
p2 <- p + geom_text_repel() + labs(title = "geom_text_repel()") # visualize this plot. it's perfect
p3 <- plotly_build(p2) # visualize now p3, you see the labels have disappeared
what can I do to visualize in my shiny app a plot as displayed in p2? Thanks