Skip to content

ggplotly() bar chart render issue #901

Open
@kporkka

Description

@kporkka

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()

ggplot chart (correct):
rplot

ggplotly() render (incorrect)
ggplotly

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions