I have the following dataframe:
df <- data.frame(party=c("Democrat", "Democrat", "Democrat", "Republican","Republican","Republican","Republican","Republican","Democrat","Democrat"), value=c(1,4,2,3,5,6,10,9,8,7), year=c(1960:1969))
I am attempting to plot year on the x axis, value on the y axis, and color by party. So the ggplot version is straightforward and it works:
library(ggplot2)
library(plotly)
p<-ggplot(df, aes(x=year, y=value, color=party, group=1))+geom_line()
p
My problem is when trying to convert this to a plotly object using ggplotly.
ggplotly(p)
It seems that the group=1 option in the ggplot aesthetics that forces the line to be a single line that is segmented by color doesn't carry over to ggplotly at all. Can anyone point to a way to fix this? I've searched for a few hours now, to no avail.


