2017-08-03 88 views

回答

0

你可以使用數字1,2,3,...的順序,直到nrow(df)爲x變量,並提供自己的刻度線。例如:

df = data.frame(date=c("1 Aug","1 Aug","2 Aug","3 Aug"),value=c(1,1.2,2,4)) 

plot_ly(df, x =1:nrow(df), 
     y =~value,type="scatter", 
     mode="lines") %>% 
    layout(xaxis=list(tickmode = 'array', 
        tickvals = 1:nrow(df), 
        ticktext = df$date, 
        range = c(0.5, nrow(df)+0.5))) 

結果:

enter image description here

希望這有助於!

+0

出色的工作 - 非常感謝 – Tamas