Open
Description
ggplotly() renders a layered bar chart incorrectly; results in stacked bars, see the figures. Any way to remedy? Thanks, Kimmo
data_before = data.frame(
year = c(2014,2014,2014,2015,2015,2015,2016,2016,2016),
pet = c("dog","cat","bird","dog","cat","bird","dog","cat","bird"),
wt = c(56, 25, 26, 10, 19, 41, 16, 17, 13)
)
data_after = data.frame(
year = c(2014,2014,2014,2015,2015,2015,2016,2016,2016),
pet = c("dog","cat","bird","dog","cat","bird","dog","cat","bird"),
wt = c(49, 18, 19, 3, 12, 34, 9, 10, 6)
)
ggplot()+
geom_bar(data=data_before,aes(year,wt,fill=pet),stat="identity",position="dodge",width = 0.9,alpha=0.5)+
geom_bar(data=data_after,aes(year,wt,fill=pet),stat="identity",position="dodge",width = 0.9)+
xlab("Year") +
ylab("Weight")
ggplotly()