R:添加“工具提示";到互动情节(情节)情节、互动、提示、工具

2023-09-06 07:02:35 作者:飞车妹子雄起

我正在使用 R 编程语言.从上一篇文章(

假设我要添加一个id";列到数据集,例如

库(dplyr)df <- iris %>% mutate(id = row_number())
用Dreamweaver做的网页,里边加的flash,但最后按f12预览出现Adobe flash player安全性问题

有没有可能,当你点击"时在任何线路"上在这个图上,出现了与该行对应的数据集(即df")的信息?

谢谢

解决方案

没有运行你的代码,但你可能需要事先将所有文本准备为一个字符串在列中,并使用 text = ~tooltip_column 显示它.它可能与 一起用于行拆分

 图 <- plot_ly(类型 = 'scatter3D',x = -calcDataMeas2$pos_X,y = calcDataMeas2$pos_Y,z = z_value,文本 = calcDataMeas2$tube_name,场景='场景1',模式='标记',标记 = 标记)

I am using the R programming language. From a previous post (R: Plot not Fully Loading), I learned how to make interactive plots in R using plotly :

library(plotly)

iris %>% plot_ly(type = 'parcoords', line = list(color = ~as.integer(Species), 
         colorscale = list(c(0,'red'),c(0.5,'green'),c(1,'blue'))), 
         dimensions = list( list(range = c(2,4.5), label = 'Sepal Width', values = ~Sepal.Width), 
                      list(range = c(4,8), constraintrange = c(5,6), label = 'Sepal Length', values = ~Sepal.Length), 
                      list(range = c(0,2.5), label = 'Petal Width', values = ~Petal.Width), 
                      list(range = c(1,7), label = 'Petal Length', values = ~Petal.Length) ) )  

Suppose if I was to add an "id" column to the data set, e.g.

library(dplyr)
df <- iris %>% mutate(id = row_number())

Is it possible so that when you "click" on any of the "lines" on this plot, information from the dataset (i.e. "df") corresponding to row of that line appears?

Thanks

解决方案

Did not run your code, but you may need to prepare all the text as one string in the column beforehand and use text = ~tooltip_column to display it. It may work with for line splits

  fig <- plot_ly(
    type = 'scatter3D',
    x = -calcDataMeas2$pos_X,
    y = calcDataMeas2$pos_Y,
    z = z_value,
    text = calcDataMeas2$tube_name,
    scene = 'scene1',
    mode = 'markers',
    marker = marker
  )