Skip to content

Commit 067e096

Browse files
committed
Consistent argument ordering/formatting.
Fixes #1305
1 parent 37fb4c2 commit 067e096

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+932
-667
lines changed

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# ggplot2 2.0.0.9000
22

3+
* All `geom_()` and `stat_()` function now have consistent argument order:
4+
data + mapping, geom/stat/position, ..., specific arguments, common arguments
5+
to all layers (#1305). This may break code if you were previously relying on
6+
partial name matching, but in the long-term should make ggplot2 easier to
7+
use.
8+
39
* `stat_ecdf()` does a better job of adding padding to -Inf/Inf, and gains
410
an argument `pad` to suppress the padding if not needed (#1467).
511

R/geom-abline.r

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ NULL
6969
#' facet_wrap(~ cyl)
7070
geom_abline <- function(mapping = NULL, data = NULL,
7171
...,
72-
slope, intercept,
73-
na.rm = FALSE, show.legend = NA) {
72+
slope,
73+
intercept,
74+
na.rm = FALSE,
75+
show.legend = NA) {
7476

7577
# If nothing set, default to y = x
7678
if (missing(mapping) && missing(slope) && missing(intercept)) {

R/geom-bar.r

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,14 @@
7373
#' }
7474
#' ggplot(mpg, aes(reorder_size(class))) + geom_bar()
7575
#' }
76-
geom_bar <- function(mapping = NULL, data = NULL, stat = "count",
77-
position = "stack", width = NULL, binwidth = NULL, ...,
78-
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) {
76+
geom_bar <- function(mapping = NULL, data = NULL,
77+
stat = "count", position = "stack",
78+
...,
79+
width = NULL,
80+
binwidth = NULL,
81+
na.rm = FALSE,
82+
show.legend = NA,
83+
inherit.aes = TRUE) {
7984

8085
if (!is.null(binwidth)) {
8186
warning("`geom_bar()` no longer has a `binwidth` parameter. ",

R/geom-bin2d.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,12 @@
1919
#'
2020
#' # Or by specifying the width of the bins
2121
#' d + geom_bin2d(binwidth = c(0.1, 0.1))
22-
geom_bin2d <- function(mapping = NULL, data = NULL, stat = "bin2d",
23-
position = "identity", na.rm = FALSE,
24-
show.legend = NA, inherit.aes = TRUE, ...) {
22+
geom_bin2d <- function(mapping = NULL, data = NULL,
23+
stat = "bin2d", position = "identity",
24+
...,
25+
na.rm = FALSE,
26+
show.legend = NA,
27+
inherit.aes = TRUE) {
2528

2629
layer(
2730
data = data,

R/geom-blank.r

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,11 @@
2121
#' # Switching to geom_blank() gets the desired plot
2222
#' c <- ggplot(mtcars, aes(x = wt, y = mpg)) + geom_blank()
2323
#' c + geom_abline(aes(intercept = a, slope = b), data = df)
24-
geom_blank <- function(mapping = NULL, data = NULL, stat = "identity",
25-
position = "identity", show.legend = NA,
26-
inherit.aes = TRUE, ...) {
24+
geom_blank <- function(mapping = NULL, data = NULL,
25+
stat = "identity", position = "identity",
26+
...,
27+
show.legend = NA,
28+
inherit.aes = TRUE) {
2729
layer(
2830
data = data,
2931
mapping = mapping,

R/geom-boxplot.r

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,20 @@
8585
#' stat = "identity"
8686
#' )
8787
#' }
88-
geom_boxplot <- function(mapping = NULL, data = NULL, stat = "boxplot",
89-
position = "dodge", outlier.colour = NULL,
90-
outlier.shape = 19, outlier.size = 1.5,
91-
outlier.stroke = 0.5, notch = FALSE, notchwidth = 0.5,
92-
varwidth = FALSE, na.rm = FALSE,
93-
show.legend = NA, inherit.aes = TRUE, ...,
94-
outlier.color = NULL) {
88+
geom_boxplot <- function(mapping = NULL, data = NULL,
89+
stat = "boxplot", position = "dodge",
90+
...,
91+
outlier.colour = NULL,
92+
outlier.color = NULL,
93+
outlier.shape = 19,
94+
outlier.size = 1.5,
95+
outlier.stroke = 0.5,
96+
notch = FALSE,
97+
notchwidth = 0.5,
98+
varwidth = FALSE,
99+
na.rm = FALSE,
100+
show.legend = NA,
101+
inherit.aes = TRUE) {
95102
layer(
96103
data = data,
97104
mapping = mapping,

R/geom-contour.r

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,15 @@
3333
#' v + geom_raster(aes(fill = density)) +
3434
#' geom_contour(colour = "white")
3535
#' }
36-
geom_contour <- function(mapping = NULL, data = NULL, stat = "contour",
37-
position = "identity", lineend = "butt",
38-
linejoin = "round", linemitre = 1,
39-
na.rm = FALSE, show.legend = NA,
40-
inherit.aes = TRUE, ...) {
36+
geom_contour <- function(mapping = NULL, data = NULL,
37+
stat = "contour", position = "identity",
38+
...,
39+
lineend = "butt",
40+
linejoin = "round",
41+
linemitre = 1,
42+
na.rm = FALSE,
43+
show.legend = NA,
44+
inherit.aes = TRUE) {
4145
layer(
4246
data = data,
4347
mapping = mapping,

R/geom-count.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,12 @@
4040
#' scale_size_area(max_size = 10)
4141
#' d + geom_count(aes(size = ..prop.., group = clarity)) +
4242
#' scale_size_area(max_size = 10)
43-
geom_count <- function(mapping = NULL, data = NULL, stat = "sum",
44-
position = "identity", na.rm = FALSE,
45-
show.legend = NA, inherit.aes = TRUE, ...) {
43+
geom_count <- function(mapping = NULL, data = NULL,
44+
stat = "sum", position = "identity",
45+
...,
46+
na.rm = FALSE,
47+
show.legend = NA,
48+
inherit.aes = TRUE) {
4649
layer(
4750
data = data,
4851
mapping = mapping,

R/geom-crossbar.r

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
#' @export
22
#' @rdname geom_linerange
3-
geom_crossbar <- function(mapping = NULL, data = NULL, stat = "identity",
4-
position = "identity", fatten = 2.5, na.rm = FALSE,
5-
show.legend = NA, inherit.aes = TRUE, ...) {
3+
geom_crossbar <- function(mapping = NULL, data = NULL,
4+
stat = "identity", position = "identity",
5+
...,
6+
fatten = 2.5,
7+
na.rm = FALSE,
8+
show.legend = NA,
9+
inherit.aes = TRUE) {
610
layer(
711
data = data,
812
mapping = mapping,

R/geom-curve.r

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
#' @inheritParams grid::curveGrob
22
#' @export
33
#' @rdname geom_segment
4-
geom_curve <- function(mapping = NULL, data = NULL, stat = "identity",
5-
position = "identity", curvature = 0.5, angle = 90,
6-
ncp = 5, arrow = NULL, lineend = "butt",
7-
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE, ...) {
4+
geom_curve <- function(mapping = NULL, data = NULL,
5+
stat = "identity", position = "identity",
6+
...,
7+
curvature = 0.5,
8+
angle = 90,
9+
ncp = 5,
10+
arrow = NULL,
11+
lineend = "butt",
12+
na.rm = FALSE,
13+
show.legend = NA,
14+
inherit.aes = TRUE) {
815
layer(
916
data = data,
1017
mapping = mapping,

0 commit comments

Comments
 (0)