title: How to customize hover text for plotly boxplots in R
body: <p>I understand how to customize the hover text for scatter plots in <code>plotly</code>, but box plots do not accept the 'text' attribute. <code>Warning message: 'box' objects don't have these attributes: 'text'</code>. I have over 300 x-axis variables and there are numbered samples(1-50) in two groups(A or B) that I want to plot together in the same box plot, then I'd like to differentiate between the sample numbers and groups through hover text when moving the cursor over outliers. I'd like to have my custom data labels instead of the automatic quartile labels. Is that possible with <code>plotly</code> boxplots?  </p>
  
  <pre><code>library(plotly) 
  library(magrittr)
  
  plot_ly(melt.s.data, 
            x = ~variable, 
            y = ~value,
            type = 'box', 
            text = ~paste("Sample number: ", Sample_number, 
                         '&lt;br&gt;Group:', Group)) %&gt;% 
          layout(title = "Individual distributions at each x")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/jsV2G.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jsV2G.jpg" alt="plotly box plot with quartile information in hover info"></a>
  Here is some sample data showing only 5 x variables (but the code should work when extrapolated to my 300)...</p>
  
  <pre><code>#sample data
  set.seed(456)
  #Group A
  sample.data_a &lt;- data.frame(Class = "red", Group = "A",
                              Sample_number = seq(1,50,by=1), 
                              x1= rnorm(50,mean=0, sd=.5), 
                              x2= rnorm(50,mean=0.5, sd=1.5), 
                              x3= rnorm(50,mean=5, sd=.1), 
                              x4= rnorm(50,mean=0, sd=3.5),
                              x5= rnorm(50,mean=-6, sd=.005))
  #Group B
  sample.data_b &lt;- data.frame(Class = "red", Group = "B",
                              Sample_number = seq(1,50,by=1), 
                              x1= rnorm(50,mean=0, sd=5.5), 
                              x2= rnorm(50,mean=0.5, sd=7.5), 
                              x3= rnorm(50,mean=5, sd=.01), 
                              x4= rnorm(50,mean=0, sd=.5),
                              x5= rnorm(50,mean=-6, sd=2.05))
  
  #row Bind groups 
  sample.data &lt;- rbind(sample.data_a, sample.data_b)
  
  #melting data to have a more graphable format
  library(reshape2)
  melt.s.data&lt;-melt(sample.data, id.vars=c("Class", "Group","Sample_number"))
  </code></pre>
  
  <p>The following are similar questions:</p>
  
  <ul>
  <li><a href="https://community.plot.ly/t/boxplot-hoverinfo-text-not-display/1959" rel="nofollow noreferrer">Here</a> it seems like it is not possible.  </li>
  <li>This <a href="https://stackoverflow.com/questions/47602651/custom-hover-effects-for-each-point-in-plotly-boxplot-with-markers-in-r">question</a> is similar, but only wants to add relevant quartile info.  </li>
  <li>And this <a href="https://stackoverflow.com/questions/41598448/how-to-add-text-to-a-plotly-boxplot-in-r">question</a> is only about a single point in plotly boxplots.  </li>
  </ul>