Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress default text in tooltip using plot_ly

Tags:

r

plotly

With plot_ly(), I am able to add what I want in the tool tip, but I don't manage to get rid of the default value. Is there way to do this ?

In the example below, for the first point, the tooltip is "250 company1". I would like to get only "company1". I have a solution using ggplot2 and then ggplotly() with the tooltip option, but I would rather remain with plotly only.

require(plotly)

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)
plot_ly(data=d,x=seq,y=value,text=name)
like image 654
Malta Avatar asked Oct 21 '25 05:10

Malta


1 Answers

You need the hoverinfo parameter for plot_ly:

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)
plot_ly(data=d,x=seq,y=value,text=name,hoverinfo="text")

More reading: plotly R chart attribute reference

like image 56
m-dz Avatar answered Oct 22 '25 19:10

m-dz