R 在X轴上绘出X坐标
我正在尝试创建一个x轴格式与此类似的图形(从): 所给代码:R 在X轴上绘出X坐标,r,plotly,R,Plotly,我正在尝试创建一个x轴格式与此类似的图形(从): 所给代码: library(plotly) x <- c(1:100) random_y <- rnorm(100, mean = 0) data <- data.frame(x, random_y) p <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines') library(plotly) x尝试设置为'x' p <-
library(plotly)
x <- c(1:100)
random_y <- rnorm(100, mean = 0)
data <- data.frame(x, random_y)
p <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines')
library(plotly)
x尝试设置为'x'
p <- plot_ly(data, x = ~x, y = ~random_y, type = 'scatter', mode = 'lines') %>% layout(hovermode = 'x')
p%布局(悬停模式='x')
它应该可以工作。在玩了一会儿之后,似乎hovermode
显示了图形上具有相同x坐标的所有点,但没有显示x轴上的实际x坐标(如第一张图片所示)。可能是版本问题吗?奇怪。。。我有完全相同的版本。你在哪个操作系统上?MacOS Sierra:10.12.6。看起来需要将hovermode设置为“x”,而hoverinfo需要设置为“text+x”才能工作。