tidyverse / tidyverse/ggplot2

Wrong x range when using coord_cartesian() with zero range xlim and expand=FALSE

Open
#3,531 4 comments 0 reactions 0 assignees View on GitHub

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)

image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.