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
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# ggplot2 (development version)

* The `arrow` and `arrow.fill` arguments are now available in
`geom_linerange()` and `geom_pointrange()` layers (@teunbrand, #6481).
* (internal) `zeroGrob()` now returns a `grid::nullGrob()` (#6390).
* `stat_ydensity()` now only requires the `x` or `y` aesthetic. The other will
be populated with 0, similar to `stat_boxplot()` (@teunbrand, #6600)
Expand Down
11 changes: 9 additions & 2 deletions R/geom-linerange.R
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,18 @@ GeomLinerange <- ggproto(
data
},

draw_panel = function(data, panel_params, coord, lineend = "butt", flipped_aes = FALSE, na.rm = FALSE) {
draw_panel = function(data, panel_params, coord, lineend = "butt",
flipped_aes = FALSE, na.rm = FALSE,
arrow = NULL, arrow.fill = NULL) {
data <- flip_data(data, flipped_aes)
data <- transform(data, xend = x, y = ymin, yend = ymax)
data <- flip_data(data, flipped_aes)
ggname("geom_linerange", GeomSegment$draw_panel(data, panel_params, coord, lineend = lineend, na.rm = na.rm))
grob <- GeomSegment$draw_panel(
data, panel_params, coord,
lineend = lineend, na.rm = na.rm,
arrow = arrow, arrow.fill = arrow.fill
)
ggname("geom_linerange", grob)
},

rename_size = TRUE
Expand Down
23 changes: 12 additions & 11 deletions R/geom-pointrange.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,24 @@ GeomPointrange <- ggproto("GeomPointrange", Geom,
},

draw_panel = function(data, panel_params, coord, lineend = "butt", fatten = 4,
flipped_aes = FALSE, na.rm = FALSE) {
flipped_aes = FALSE, na.rm = FALSE,
arrow = NULL, arrow.fill = NULL) {
line_grob <- GeomLinerange$draw_panel(
data, panel_params, coord, lineend = lineend, flipped_aes = flipped_aes,
na.rm = na.rm
na.rm = na.rm, arrow = arrow, arrow.fill = arrow.fill
)
if (is.null(data[[flipped_names(flipped_aes)$y]]))

skip_point <- is.null(data[[flipped_names(flipped_aes)$y]])
if (skip_point) {
return(line_grob)
}

ggname("geom_pointrange",
gTree(children = gList(
line_grob,
GeomPoint$draw_panel(
transform(data, size = size * fatten),
panel_params, coord, na.rm = na.rm
)
))
point_grob <- GeomPoint$draw_panel(
transform(data, size = size * fatten),
panel_params, coord, na.rm = na.rm
)
grob <- gTree(children = gList(line_grob, point_grob))
ggname("geom_pointrange", grob)
}
)

Expand Down
10 changes: 10 additions & 0 deletions man/geom_linerange.Rd

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

26 changes: 14 additions & 12 deletions tests/testthat/_snaps/function-args.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
Code
problems
Output
[1] "GeomBoxplot : `notch` with `notchwidth`"
[2] "GeomContour : `arrow` with `arrow.fill`"
[3] "GeomCurve : `arrow` with `arrow.fill`"
[4] "GeomDensity2d: `arrow` with `arrow.fill`"
[5] "GeomFunction : `arrow` with `arrow.fill`"
[6] "GeomLine : `arrow` with `arrow.fill`"
[7] "GeomPath : `arrow` with `arrow.fill`"
[8] "GeomQuantile : `arrow` with `arrow.fill`"
[9] "GeomSegment : `arrow` with `arrow.fill`"
[10] "GeomSf : `arrow` with `arrow.fill`"
[11] "GeomSpoke : `arrow` with `arrow.fill`"
[12] "GeomStep : `arrow` with `arrow.fill`"
[1] "GeomBoxplot : `notch` with `notchwidth`"
[2] "GeomContour : `arrow` with `arrow.fill`"
[3] "GeomCurve : `arrow` with `arrow.fill`"
[4] "GeomDensity2d : `arrow` with `arrow.fill`"
[5] "GeomFunction : `arrow` with `arrow.fill`"
[6] "GeomLine : `arrow` with `arrow.fill`"
[7] "GeomLinerange : `arrow` with `arrow.fill`"
[8] "GeomPath : `arrow` with `arrow.fill`"
[9] "GeomPointrange: `arrow` with `arrow.fill`"
[10] "GeomQuantile : `arrow` with `arrow.fill`"
[11] "GeomSegment : `arrow` with `arrow.fill`"
[12] "GeomSf : `arrow` with `arrow.fill`"
[13] "GeomSpoke : `arrow` with `arrow.fill`"
[14] "GeomStep : `arrow` with `arrow.fill`"

# StatXxx$parameters() does not contain partial matches

Expand Down