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,

R/geom-density.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,12 @@
4545
#' ggplot(diamonds, aes(carat, ..count.., fill = cut)) +
4646
#' geom_density(position = "fill")
4747
#' }
48-
geom_density <- function(mapping = NULL, data = NULL, stat = "density",
49-
position = "identity", na.rm = FALSE,
50-
show.legend = NA, inherit.aes = TRUE, ...) {
48+
geom_density <- function(mapping = NULL, data = NULL,
49+
stat = "density", position = "identity",
50+
...,
51+
na.rm = FALSE,
52+
show.legend = NA,
53+
inherit.aes = TRUE) {
5154

5255
layer(
5356
data = data,

R/geom-density2d.r

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,15 @@
3434
#' # Or points:
3535
#' d + stat_density_2d(geom = "point", aes(size = ..density..), n = 20, contour = FALSE)
3636
#' }
37-
geom_density_2d <- function(mapping = NULL, data = NULL, stat = "density2d",
38-
position = "identity", ...,
39-
lineend = "butt", linejoin = "round", linemitre = 1,
40-
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) {
37+
geom_density_2d <- function(mapping = NULL, data = NULL,
38+
stat = "density2d", position = "identity",
39+
...,
40+
lineend = "butt",
41+
linejoin = "round",
42+
linemitre = 1,
43+
na.rm = FALSE,
44+
show.legend = NA,
45+
inherit.aes = TRUE) {
4146
layer(
4247
data = data,
4348
mapping = mapping,

R/geom-dotplot.r

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,23 @@
112112
#' geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot")
113113
#' }
114114
geom_dotplot <- function(mapping = NULL, data = NULL,
115-
position = "identity", binwidth = NULL, binaxis = "x",
116-
method = "dotdensity", binpositions = "bygroup",
117-
stackdir = "up", stackratio = 1, dotsize = 1,
118-
stackgroups = FALSE, origin = NULL, right = TRUE,
119-
width = 0.9, drop = FALSE, na.rm = FALSE,
120-
show.legend = NA, inherit.aes = TRUE, ...) {
115+
position = "identity",
116+
...,
117+
binwidth = NULL,
118+
binaxis = "x",
119+
method = "dotdensity",
120+
binpositions = "bygroup",
121+
stackdir = "up",
122+
stackratio = 1,
123+
dotsize = 1,
124+
stackgroups = FALSE,
125+
origin = NULL,
126+
right = TRUE,
127+
width = 0.9,
128+
drop = FALSE,
129+
na.rm = FALSE,
130+
show.legend = NA,
131+
inherit.aes = TRUE) {
121132
# If identical(position, "stack") or position is position_stack(), tell them
122133
# to use stackgroups=TRUE instead. Need to use identical() instead of ==,
123134
# because == will fail if object is position_stack() or position_dodge()

R/geom-errorbar.r

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

R/geom-errorbarh.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,12 @@
2121
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se))
2222
#' p + geom_point() +
2323
#' geom_errorbarh(aes(xmax = resp + se, xmin = resp - se, height = .2))
24-
geom_errorbarh <- function(mapping = NULL, data = NULL, stat = "identity",
25-
position = "identity", na.rm = FALSE,
26-
show.legend = NA, inherit.aes = TRUE, ...) {
24+
geom_errorbarh <- function(mapping = NULL, data = NULL,
25+
stat = "identity", position = "identity",
26+
...,
27+
na.rm = FALSE,
28+
show.legend = NA,
29+
inherit.aes = TRUE) {
2730
layer(
2831
data = data,
2932
mapping = mapping,

R/geom-freqpoly.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#' @export
22
#' @rdname geom_histogram
3-
geom_freqpoly <- function(mapping = NULL, data = NULL, stat = "bin",
4-
position = "identity", na.rm = FALSE,
5-
show.legend = NA, inherit.aes = TRUE, ...) {
3+
geom_freqpoly <- function(mapping = NULL, data = NULL,
4+
stat = "bin", position = "identity",
5+
...,
6+
na.rm = FALSE,
7+
show.legend = NA,
8+
inherit.aes = TRUE) {
69
layer(
710
data = data,
811
mapping = mapping,

R/geom-hex.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,12 @@
2323
#' d + geom_hex(binwidth = c(1, 1000))
2424
#' d + geom_hex(binwidth = c(.1, 500))
2525
#' }
26-
geom_hex <- function(mapping = NULL, data = NULL, stat = "binhex",
27-
position = "identity", na.rm = FALSE,
28-
show.legend = NA, inherit.aes = TRUE, ...) {
26+
geom_hex <- function(mapping = NULL, data = NULL,
27+
stat = "binhex", position = "identity",
28+
...,
29+
na.rm = FALSE,
30+
show.legend = NA,
31+
inherit.aes = TRUE) {
2932
layer(
3033
data = data,
3134
mapping = mapping,

R/geom-histogram.r

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,13 @@
7171
#' }
7272
#' rm(movies)
7373
geom_histogram <- function(mapping = NULL, data = NULL,
74-
stat = "bin", position = "stack", ...,
75-
binwidth = NULL, bins = NULL,
76-
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) {
74+
stat = "bin", position = "stack",
75+
...,
76+
binwidth = NULL,
77+
bins = NULL,
78+
na.rm = FALSE,
79+
show.legend = NA,
80+
inherit.aes = TRUE) {
7781

7882
layer(
7983
data = data,

R/geom-hline.r

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ NULL
66
geom_hline <- function(mapping = NULL, data = NULL,
77
...,
88
yintercept,
9-
na.rm = FALSE, show.legend = NA) {
9+
na.rm = FALSE,
10+
show.legend = NA) {
1011

1112
# Act like an annotation
1213
if (!missing(yintercept)) {

R/geom-jitter.r

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@
3030
#' ggplot(mpg, aes(cty, hwy)) + geom_jitter()
3131
#' ggplot(mpg, aes(cty, hwy)) + geom_jitter(width = 0.5, height = 0.5)
3232
geom_jitter <- function(mapping = NULL, data = NULL,
33-
width = NULL, height = NULL, stat = "identity",
34-
position = "jitter", na.rm = FALSE,
35-
show.legend = NA, inherit.aes = TRUE, ...) {
33+
stat = "identity", position = "jitter",
34+
...,
35+
width = NULL,
36+
height = NULL,
37+
na.rm = FALSE,
38+
show.legend = NA,
39+
inherit.aes = TRUE) {
3640
if (!missing(width) || !missing(height)) {
3741
if (!missing(position)) {
3842
stop("Specify either `position` or `width`/`height`", call. = FALSE)

R/geom-label.R

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@
33
#' @param label.padding Amount of padding around label. Defaults to 0.25 lines.
44
#' @param label.r Radius of rounded corners. Defaults to 0.15 lines.
55
#' @param label.size Size of label border, in mm.
6-
geom_label <- function(mapping = NULL, data = NULL, stat = "identity",
7-
position = "identity", parse = FALSE, ...,
8-
nudge_x = 0, nudge_y = 0,
6+
geom_label <- function(mapping = NULL, data = NULL,
7+
stat = "identity", position = "identity",
8+
...,
9+
parse = FALSE,
10+
nudge_x = 0,
11+
nudge_y = 0,
912
label.padding = unit(0.25, "lines"),
10-
label.r = unit(0.15, "lines"), label.size = 0.25,
11-
na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) {
13+
label.r = unit(0.15, "lines"),
14+
label.size = 0.25,
15+
na.rm = FALSE,
16+
show.legend = NA,
17+
inherit.aes = TRUE) {
1218
if (!missing(nudge_x) || !missing(nudge_y)) {
1319
if (!missing(position)) {
1420
stop("Specify either `position` or `nudge_x`/`nudge_y`", call. = FALSE)

R/geom-linerange.r

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,12 @@
4848
#' p +
4949
#' geom_bar(position = dodge, stat = "identity") +
5050
#' geom_errorbar(aes(ymin = lower, ymax = upper), position = dodge, width = 0.25)
51-
geom_linerange <- function(mapping = NULL, data = NULL, stat = "identity",
52-
position = "identity", na.rm = FALSE,
53-
show.legend = NA, inherit.aes = TRUE, ...) {
51+
geom_linerange <- function(mapping = NULL, data = NULL,
52+
stat = "identity", position = "identity",
53+
...,
54+
na.rm = FALSE,
55+
show.legend = NA,
56+
inherit.aes = TRUE) {
5457
layer(
5558
data = data,
5659
mapping = mapping,

0 commit comments

Comments
 (0)