【问题标题】:Change information on hover of Plotly point更改 Plotly 点悬停信息
【发布时间】:2020-06-01 22:09:42
【问题描述】:

我在 R 中使用 Plotly 制作散点图,但目前当我将鼠标悬停在闪亮应用程序中的点上时,会出现与 x,y 值对应的值。例如 (19, 27.73k)。但是,我想将其更改为也显示与该数据对应的列。 ex (USA, 19, 27.73k) 这可能吗? IDK(如果相关但当前标记代码)

mode="markers", 
               marker = list(
                 opacity = 0.5, 
                 size = 5
               )) %>% 

【问题讨论】:

  • 这是here library(plotly) fig <- plot_ly(type = 'scatter', mode = 'markers') fig <- fig %>% add_trace( x = c(1:5), y = rnorm(5, mean = 5), text = c("Text A", "Text B", "Text C", "Text D", "Text E"), hoverinfo = 'text', marker = list(color='green'), showlegend = F ) fig 的摘录 为了为您的数据提供解决方案,使用 dput 或其他方式获取一些示例数据会有所帮助。

标签: r plotly


【解决方案1】:

您正在寻找的是hovertemplate,可能与text 一起出现。如果没有数据,很难准确地生成您需要的内容,但您应该能够在 https://plotly.com/r/hover-text-and-formatting/

找到它

【讨论】:

    猜你喜欢
    • 2016-07-12
    • 1970-01-01
    • 2018-09-04
    • 1970-01-01
    • 2018-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-13
    相关资源
    最近更新 更多