Wrong x range when using coord_cartesian() with zero range xlim and expand=FALSE
Open
Nobody has claimed this yet.
coord :world_map:
- Dominant language
- R
- Stars
- 7k
- Forks
- 2.1k
- Avg merge
- 59m
- Merged PRs (30d)
- 2
Description
When coord_cartesian() is called a zero-range xlim and expand=FALSE, the x value appears to be treated as a factor, and all points are in the plot.
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
coord_cartesian(xlim = c(5, 5), expand = FALSE)

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 coord_cartesian() example with mtcars, xlim = c(5, 5), and expand = FALSE, then trace the coord_cartesian() handling of zero-range limits. Done means the range is treated numerically and only the intended x value is shown; add a regression test for this case if the repository's testing structure identifies a suitable location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100