我想设置标签,只显示光标指向的值。相反,当前代码显示任何x值的所有y值。
library(plotly)
data_frame(noiseLevel=sort(rep(seq(10,50,10),5)),
temperature=rep(seq(50,90,10),5),
testScore=c(30,75,20,50,70,
40,60,45,20,50,
30,20,30,40,30,
60,30,60,20,50,
30,50,20,40,60)) -> dt
plot_ly(data=dt,
x = noiseLevel,
y = testScore,
color=factor(temperature),
name = "linear", line = list(shape = "linear"))
答案 0 :(得分:0)
正如rld01所提到的,这可以在工具栏中更改,但您也可以通过R更改默认值。这是代码。
library(plotly)
data.frame(noiseLevel=sort(rep(seq(10,50,10),5)),
temperature=rep(seq(50,90,10),5),
testScore=c(30,75,20,50,70,
40,60,45,20,50,
30,20,30,40,30,
60,30,60,20,50,
30,50,20,40,60)) -> dt
plot_ly(data=dt,
x = noiseLevel,
y = testScore,
color=factor(temperature),
name = "linear", line = list(shape = "linear")) %>%
layout(hovermode="closest")
# with upcoming plotly
# devtools::install_github("ropensci/plotly")
plot_ly(data=dt,
x = ~noiseLevel,
y = ~testScore,
color=~factor(temperature),
name = "linear", line = list(shape = "linear")) %>%
layout(hovermode="closest")