Skip to content

Additional Information in Hovertext #549

@yankev

Description

@yankev

Example:

library(plotly)
p <- mtcars %>% 
  plot_ly(x = disp, y = mpg, mode = "markers", color = cyl, size = wt, 
          hoverinfo = "text",
          text = paste("Displacement = ", mtcars$disp, "Miles Per Gallon = ", mtcars$mpg)) %>% 
  layout(title ="Custom Hover Text")
p

text should only contain displacement and mpg, however wt shows up in the hovertext.

screen shot 2016-04-14 at 12 37 52 pm

Taking a look at underlying plot definition:

> pp <- plotly_build(p)
> head(pp$data[[1]]$text)
[1] "Displacement =  160 Miles Per Gallon =  21<br>wt (size): 2.62"   
[2] "Displacement =  160 Miles Per Gallon =  21<br>wt (size): 2.875"  
[3] "Displacement =  108 Miles Per Gallon =  22.8<br>wt (size): 2.32" 
[4] "Displacement =  258 Miles Per Gallon =  21.4<br>wt (size): 3.215"
[5] "Displacement =  360 Miles Per Gallon =  18.7<br>wt (size): 3.44" 
[6] "Displacement =  225 Miles Per Gallon =  18.1<br>wt (size): 3.46" 
> sessionInfo()
R version 3.2.3 (2015-12-10)
Platform: x86_64-apple-darwin13.4.0 (64-bit)
Running under: OS X 10.9.4 (Mavericks)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] plotly_3.4.13 ggplot2_2.1.0

loaded via a namespace (and not attached):
 [1] Rcpp_0.12.4      knitr_1.12       magrittr_1.5     devtools_1.9.1   munsell_0.4.3    colorspace_1.2-6
 [7] R6_2.1.2         httr_1.1.0       plyr_1.8.3       dplyr_0.4.3      tools_3.2.3      parallel_3.2.3  
[13] grid_3.2.3       gtable_0.2.0     DBI_0.3.1        htmltools_0.3.5  yaml_2.1.13      digest_0.6.9    
[19] assertthat_0.1   gridExtra_2.2.1  tidyr_0.4.1      base64enc_0.1-3  htmlwidgets_0.6  viridis_0.3.4   
[25] curl_0.9.7       memoise_0.2.1    scales_0.4.0     jsonlite_0.9.19 

Original source: http://stackoverflow.com/questions/36596849/how-can-i-remove-the-size-line-in-the-hoverinfo-of-a-plotly-chart-in-r

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions