I have a simple data frame:
seq <- 1:10
name <- c(paste0(\"company\",1:10))
value <- c(250,125,50,40,40,30,20,20,10,10)
d <- data.frame(seq,name,
You'll have to modify the plotly object to do this. Or use plot_ly() to create the graph instead...
EDIT:
With the release of plotly 4.0 the syntax will change a little bit.
seq <- 1:10
name <- c(paste0("company",1:10))
value <- c(250,125,50,40,40,30,20,20,10,10)
d <- data.frame(seq,name,value)
require(plotly)
gg <- ggplot(data = d,aes(x=seq,y=value))+geom_line() + geom_point()
gg <- plotly_build(gg)
#OLD:
gg$data[[1]]$text <- paste("Seq:", d$seq, "
",
"Value:", d$value, "
",
"Company:", d$name)
#UPDATED:
#Plotly_build creates two separate traces:
#One with mode = markers and the other with mode = lines
#Hence modify text for the second trace
gg$x$data[[2]]$text <- paste("Seq:", d$seq, "
",
"Value:", d$value, "
",
"Company:", d$name)
gg