2016-07-18 5 views
0

커서로 가리키는 값만 표시되도록 레이블을 설정하고 싶습니다. 대신 현재 코드는 모든 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

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") 
관련 문제