position_dodge() with order aesthetics for stacking and dodging
Open
Nobody has claimed this yet.
positions :1st_place_medal:
- Dominant language
- R
- Stars
- 7k
- Forks
- 2.1k
- Avg merge
- 59m
- Merged PRs (30d)
- 2
Description
This plots as expected:
ggplot(mpg, aes(x = class, order = drv, fill = drv)) +
geom_bar(position = position_dodge(preserve = "single")) +
theme_bw()
This one is almost correct, but it seems the widths of the bars take into account the number of groups (5) rather then the number of distinct order values (3):
ggplot(mutate(mpg, drvXyear = paste0(drv, "|", year)),
aes(x = class, order = drv, fill = drvXyear)) +
geom_bar(position = position_dodge(preserve = "single")) +
theme_bw()
ggplot2 v4.0.1
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 reproducing the two R examples with ggplot2 4.0.1, focusing on the position_dodge() entry point and its preserve = "single" behavior. Trace how order and fill groups determine bar widths, then verify that the second plot uses the three distinct order values rather than the five fill groups.
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