Add multiple lines to a plot_ly graph with add_trace

前端 未结 3 1555
日久生厌
日久生厌 2021-02-20 06:59

I found an example to add lines to a plot_ly plot by using the add_trace command. How can I add a list of lines to plot without using add_trace

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-20 07:45

    I believe with the release of plotly 4.0 calling any of the add_* family of functions forces evaluation so there is no need to call evaluate = T anymore

    So, something like this should work fine:

    devtools::install_github("ropensci/plotly")
    library(plotly)
    
    p <- plot_ly()
    
    for(i in 1:5){
      p <- add_trace(p, x = 1:10, y = rnorm(10), mode = "lines")
    }
    
    p
    

提交回复
热议问题