I'm trying to build an interactive chart using plotly, but it's failing to show the geom_line()
and I'm not sure why. This isn't my exact example, but even the example provided on plotly's webpage fails. Here it is:
library(plotly)
datn <- read.table(header=TRUE, text='
supp dose length
OJ 0.5 13.23
OJ 1.0 22.70
OJ 2.0 26.06
VC 0.5 7.98
VC 1.0 16.77
VC 2.0 26.14
')
## This one works fine (original example):
ggplot(data=datn, aes(x=dose, y=length, group=supp, colour=supp)) + geom_line() + geom_point()
ggplotly()
## This one doesn't (modified the group):
ggplot(data=datn, aes(x=dose, y=length, group=dose, colour=supp)) + geom_line() + geom_point()
ggplotly()
Which looks like this after the ggplot
:
But the ggplotly
looks like this:
What gives? Tried: The appliance of geom_line() in ggplot() and ggplotly not displaying geom_line correctly to no avail.
UPDATE: If I omit the color, the lines plot correctly:
ggplot(data=datn, aes(x=dose, y=length, group=dose)) +
geom_line(aes(group=dose)) + geom_point()
ggplotly()
So I could always just assign the geom_point()
properties at geom_point()
per se, but why?