`geom_vline()` and friends cannot use `mapping` when `xintercept` is set
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 7k
- Forks
- 2.1k
- Avg merge
- 59m
- Merged PRs (30d)
- 2
Description
I wanted to make geom_vline() adopt the theme's accent colour. Below was my sequence of attempts:
library(ggplot2)
ggplot() + geom_vline(xintercept = 0, colour = from_theme(accent))
#> Error:
#> ! object 'accent' not found
ggplot() + geom_vline(aes(colour = from_theme(accent)), xintercept = 0)
#> Warning: `geom_vline()`: Ignoring `mapping` because `xintercept` was provided.

ggplot() + geom_vline(aes(xintercept = 0, colour = from_theme(accent)))

Created on 2026-04-03 with reprex v2.1.1
The first is obviously wrong because from_theme() only works inside aes(). The second seems like it should work, but the geoms are being too strict.
In the past I understand why it might have been discouraged to use mapping, but I think with the newer features like from_theme() the situation changed a bit and the limitation seems unnecessary.
Would it be worth making geom_vline(aes(colour = from_theme(accent)), xintercept = 0) work?
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 at the geom_vline() implementation and trace how it handles mapping when xintercept is supplied, including the related geoms mentioned in the issue. Confirm the behavior with the provided from_theme(accent) example; done means mapping is accepted alongside xintercept without the warning and the line uses the theme accent colour.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- data-visualization
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100