Using both group and color in plotly
问题 I am trying to plot a number of dimensions in r using plotly - is it possible to use both color and group parameters on factor variables to have a line that changes color? Example: grp <- c(letters[c(1,1,1,1,2,2,2,2)]) a <- c(1,2,3,4,2,3,4,5) b <- c(1,3,5,6,1,2,4,4) lvl <- c(1,1,2,2,1,1,2,2) df <- data.frame(grp, a, b, lvl) When plotting this using ggplot() I am able to create the desired effect as below, with grp as to define each line and lvl to define the color of sections of the line: