ggplotly() bar chart render issue
Open
Nobody has claimed this yet.
bug
ggplotly
- Dominant language
- R
- Stars
- 2.7k
- Forks
- 641
- PR merge metrics
- No merged PRs in 30d
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()
ggplot chart (correct):

ggplotly() render (incorrect)

Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied R reproduction and compare the ggplot and ggplotly figures, focusing on the two layered geom_bar calls using position="dodge". Trace how this chart is converted and rendered, then verify that the ggplotly result preserves the separate dodged bars and transparency shown by the source chart.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100