How can I combine a line and scatter on same plotly chart?

前端 未结 3 498
说谎
说谎 2021-01-22 02:24

The two separate charts created from data.frame work correctly when created using the R plotly package.
However, I am not sure how to combine them into one (presumably with

3条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-22 02:58

    here is a way to do what you want, but with ggplot2 :-) You can change the background, line, points color as you want.

    library(ggplot2)
    library(plotly)
        df_s <- df[c(3:4), ]
    
        p <- ggplot(data=df, aes(x = game, y = value, color = season)) +
          geom_point(size = 4) +
          geom_line(data=df_s, aes(x = game, y = value, color = season))
    
        (gg <- ggplotly(p))
    

提交回复
热议问题