thank you for your help, the last link worked but it shows the last title for all plots.
because I have some subplots and their number is unknown.
please see my code:
output$fancyPlot <- renderPlotly({
s = input$fancyTable_rows_selected
for (i in 1: length(s)) {
mat = matrix(ncol = 0, nrow = 0)
E = data.frame(mat)
E2 = P2[[i]]
E2 = as.data.frame(E2)
E1 = P1[[i]]
E1 = as.data.frame(E1)
E = cbind(E1, E2)
colnames(E) = c("group1", "group2")
w1 = group1_vectors[i]
w2 = group2_vectors[i]
w3 = gene_vectors[i]
plot1 = ggplot(E, aes(x = group1 , y = group2)) +
geom_point(color='tomato')
plot_list_final[[i]] = plot1
}
plot_list_final = do.call(tagList, plot_list_final)
f = length(s)
p_last <- subplot(plot_list_final[1:f], shareX = TRUE, shareY = TRUE)
p_last %>% layout(annotations = list(text = w3[1:f] ,showarrow = F, xref='paper', yref='paper')) #based on your link
dev.off()
return(p_last)
})