Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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).


* 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 @@ -69,11 +69,13 @@ NULL
#' geom_hline(aes(yintercept = wt, colour = wt), mean_wt) +
#' facet_wrap(~ cyl)
geom_abline <- function(mapping = NULL, data = NULL,
stat = "identity",
...,
slope,
intercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
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
9 changes: 5 additions & 4 deletions R/geom-hline.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ NULL
#' @export
#' @rdname geom_abline
geom_hline <- function(mapping = NULL, data = NULL,
position = "identity",
stat = "identity", position = "identity",
...,
yintercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
inherit.aes = FALSE) {

# Act like an annotation
if (!missing(yintercept)) {
Expand All @@ -28,11 +29,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
9 changes: 5 additions & 4 deletions R/geom-vline.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ NULL
#' @export
#' @rdname geom_abline
geom_vline <- function(mapping = NULL, data = NULL,
position = "identity",
stat = "identity", position = "identity",
...,
xintercept,
na.rm = FALSE,
show.legend = NA) {
show.legend = NA,
inherit.aes = FALSE) {

# Act like an annotation
if (!missing(xintercept)) {
Expand All @@ -28,11 +29,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
30 changes: 27 additions & 3 deletions man/geom_abline.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading