Using 2+ legends from R to plotly / plot.ly

筅森魡賤 提交于 2019-11-29 15:56:53

I replied to you over email but I'll post here for everyone. ;)

You ran into a bug, and we were able to fix it quickly thanks to your feedback. :)

Please reinstall and reload the "plotly" package, re-instantiate your py object and it should work now: https://plot.ly/~marianne2/38/or-illn-vs-or-edu/

Let me reply on your 'hover' question in a separate post.

Thanks again for the feedback!

Okay, I can then move this reply where it belongs. To edit what appears in the hover box:

# Load "plotly"
library(plotly)
# Open a Plotly connection
py <- plotly()

# Retrieve a Plotly graph in R
hover_text <- py$get_figure("PlotBot", 81)

str(hover_text$data)
# This list has 4 elements, which all have dimension (attribute) 'text'

# You can overwrite them one by one, say
hover_text$data[[1]]$text[1]
hover_text$data[[1]]$text[1] <- "US"

# If you need something functional, I would recommend defining the necessary
# functions and using sapply()

# Plotly graph with hover text we just edited
py$plotly(hover_text$data, kwargs=list(layout=hover_text$layout))
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!