Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
* Fixed regression where `draw_key_rect()` stopped using `fill` colours
(@mitchelloharawild, #6609).

### Improvements
* Allow `stat` in `geom_hline`, `geom_vline`, and `geom_abline`. (@sierrajohnson, #6559)

# ggplot2 4.0.0

## User facing
Expand Down
8 changes: 5 additions & 3 deletions R/geom-abline.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ geom_abline <- function(mapping = NULL, data = NULL,
slope,
intercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
stat = "identity",
inherit.aes = FALSE) {

# If nothing set, default to y = x
if (is.null(mapping) && missing(slope) && missing(intercept)) {
Expand Down Expand Up @@ -108,11 +110,11 @@ geom_abline <- function(mapping = NULL, data = NULL,
layer(
data = data,
mapping = mapping,
stat = StatIdentity,
stat = stat,
geom = GeomAbline,
position = PositionIdentity,
show.legend = show.legend,
inherit.aes = FALSE,
inherit.aes = inherit.aes,
params = list2(
na.rm = na.rm,
...
Expand Down
8 changes: 5 additions & 3 deletions R/geom-hline.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ geom_hline <- function(mapping = NULL, data = NULL,
...,
yintercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
stat = "identity",
inherit.aes = FALSE) {

# Act like an annotation
if (!missing(yintercept)) {
Expand All @@ -28,11 +30,11 @@ geom_hline <- function(mapping = NULL, data = NULL,
layer(
data = data,
mapping = mapping,
stat = StatIdentity,
stat = stat,
geom = GeomHline,
position = position,
show.legend = show.legend,
inherit.aes = FALSE,
inherit.aes = inherit.aes,
params = list2(
na.rm = na.rm,
...
Expand Down
8 changes: 5 additions & 3 deletions R/geom-vline.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ geom_vline <- function(mapping = NULL, data = NULL,
...,
xintercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
stat = "identity",
inherit.aes = FALSE) {

# Act like an annotation
if (!missing(xintercept)) {
Expand All @@ -28,11 +30,11 @@ geom_vline <- function(mapping = NULL, data = NULL,
layer(
data = data,
mapping = mapping,
stat = StatIdentity,
stat = stat,
geom = GeomVline,
position = position,
show.legend = show.legend,
inherit.aes = FALSE,
inherit.aes = inherit.aes,
params = list2(
na.rm = na.rm,
...
Expand Down
Loading