如何在折线图中添加垂直y轴滚动条?
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')
p
我有一个滚动条的html代码,但我不知道如何将该代码与plot 集成
Html <div style="overflow-y:scroll;height: 200px;">
使用库htmltools
。你可以完全按照你写的那样使用HTML。
library(plotly)
library(htmltools)
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')
p
# this combines the plot and your y scroll
browsable(div(style = "overflow-y: scroll; height: 200px;", p))