Skip to content

Commit 9383d2a

Browse files
authored
New roxygen tag: @aesthetics (#6437)
* implement `@aesthetics` roxy tag * Use new tag * redocument * add news bullet * add roxygen2 to Suggest * omit `ggplot2::` link prefix in ggplot2, but not extensions
1 parent 863cb95 commit 9383d2a

Some content is hidden

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

73 files changed

+711
-665
lines changed

DESCRIPTION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ Suggests:
6363
ragg (>= 1.2.6),
6464
RColorBrewer,
6565
rmarkdown,
66+
roxygen2,
6667
rpart,
6768
sf (>= 0.7-3),
6869
svglite (>= 2.1.2),

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ S3method(element_grob,element_rect)
2828
S3method(element_grob,element_text)
2929
S3method(format,ggproto)
3030
S3method(format,ggproto_method)
31+
S3method(format,rd_section_aesthetics)
3132
S3method(fortify,"NULL")
3233
S3method(fortify,"function")
3334
S3method(fortify,Line)

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# ggplot2 (development version)
22

3+
* New roxygen tag `@aesthetics` that takes a Geom, Stat or Position class and
4+
generates an 'Aesthetics' section.
35
* `annotation_borders()` replaces the now-deprecated `borders()`
46
(@teunbrand, #6392)
57
* New `make_constructor()` function that builds a standard constructor for

R/geom-bar.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ GeomBar <- ggproto(
6868
#'
6969
#' @eval rd_orientation()
7070
#'
71-
#' @eval rd_aesthetics("geom", "bar")
72-
#' @eval rd_aesthetics("geom", "col")
73-
#' @eval rd_aesthetics("stat", "count")
71+
#' @aesthetics GeomBar
72+
#' @aesthetics GeomCol
73+
#' @aesthetics StatCount
7474
#' @seealso
7575
#' [geom_histogram()] for continuous data,
7676
#' [position_dodge()] and [position_dodge2()] for creating side-by-side

R/geom-bin2d.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ GeomBin2d <- ggproto("GeomBin2d", GeomTile)
1414
#' rectangle's fill. This is a useful alternative to [geom_point()]
1515
#' in the presence of overplotting.
1616
#'
17-
#' @eval rd_aesthetics("stat", "bin_2d")
17+
#' @aesthetics GeomBin2d
1818
#'
1919
#' @export
2020
#' @inheritParams layer

R/geom-boxplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#' This gives a roughly 95% confidence interval for comparing medians.
2525
#' See McGill et al. (1978) for more details.
2626
#'
27-
#' @eval rd_aesthetics("geom", "boxplot")
27+
#' @aesthetics GeomBoxplot
2828
#'
2929
#' @seealso [geom_quantile()] for continuous `x`,
3030
#' [geom_violin()] for a richer display of the distribution, and

R/geom-contour.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ GeomContourFilled <- ggproto("GeomContourFilled", GeomPolygon)
2828
#' data, you'll need to first interpolate on to a grid before visualising,
2929
#' using `interp::interp()`, `akima::bilinear()`, or similar.
3030
#'
31-
#' @eval rd_aesthetics("geom", "contour")
32-
#' @eval rd_aesthetics("geom", "contour_filled")
31+
#' @aesthetics GeomContour
32+
#' @aesthetics GeomContourFilled
3333
#' @inheritParams layer
3434
#' @inheritParams geom_point
3535
#' @inheritParams geom_path

R/geom-count.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ NULL
77
#' observations at each location, then maps the count to point area. It
88
#' useful when you have discrete data and overplotting.
99
#'
10-
#' @eval rd_aesthetics("geom", "point")
10+
#' @aesthetics GeomPoint
1111
#' @param geom,stat Use to override the default connection between
1212
#' `geom_count()` and `stat_sum()`. For more information about overriding
1313
#' these connections, see how the [stat][layer_stats] and [geom][layer_geoms]

R/geom-density.R

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ GeomDensity <- ggproto(
2222
#' data that comes from an underlying smooth distribution.
2323
#'
2424
#' @eval rd_orientation()
25-
#'
26-
#' @eval rd_aesthetics("geom", "density")
25+
#' @aesthetics GeomDensity
2726
#' @seealso See [geom_histogram()], [geom_freqpoly()] for
2827
#' other methods of displaying continuous distribution.
2928
#' See [geom_violin()] for a compact density display.

R/geom-density2d.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
#' draws contour lines, and `geom_density_2d_filled()` draws filled contour
77
#' bands.
88
#'
9-
#' @eval rd_aesthetics("geom", "density_2d")
10-
#' @eval rd_aesthetics("geom", "density_2d_filled")
9+
#' @aesthetics GeomDensity2d
10+
#' @aesthetics GeomDensity2dFilled
1111
#' @seealso [geom_contour()], [geom_contour_filled()] for information about
1212
#' how contours are drawn; [geom_bin_2d()] for another way of dealing with
1313
#' overplotting.

R/geom-dotplot.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#' hide the y axis, as in one of the examples, or manually scale it
1717
#' to match the number of dots.
1818
#'
19-
#' @eval rd_aesthetics("geom", "dotplot")
19+
#' @aesthetics GeomDotplot
2020
#' @eval rd_computed_vars(
2121
#' x = 'center of each bin, if `binaxis` is `"x"`.',
2222
#' y = 'center of each bin, if `binaxis` is `"x"`.',

R/geom-function.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ GeomFunction <- ggproto("GeomFunction", GeomPath,
2828
#' with a grid of evenly spaced values along the x axis, and the results are
2929
#' drawn (by default) with a line.
3030
#'
31-
#' @eval rd_aesthetics("geom", "function")
31+
#' @aesthetics GeomFunction
3232
#' @param data Ignored by `stat_function()`, do not use.
3333
#' @inheritParams layer
3434
#' @inheritParams geom_path

R/geom-hex.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ GeomHex <- ggproto("GeomHex", Geom,
7373
#' fill. Hexagon bins avoid the visual artefacts sometimes generated by
7474
#' the very regular alignment of [geom_bin_2d()].
7575
#'
76-
#' @eval rd_aesthetics("geom", "hex")
77-
#' @eval rd_aesthetics("stat", "binhex")
76+
#' @aesthetics GeomHex
77+
#' @aesthetics StatBinhex
7878
#' @seealso [stat_bin_2d()] for rectangular binning
7979
#' @param geom,stat Override the default connection between `geom_hex()` and
8080
#' `stat_bin_hex()`. For more information about overriding these connections,

R/geom-jitter.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#' variation to the location of each point, and is a useful way of handling
66
#' overplotting caused by discreteness in smaller datasets.
77
#'
8-
#' @eval rd_aesthetics("geom", "point")
8+
#' @aesthetics GeomPoint
99
#' @inheritParams layer
1010
#' @inheritParams geom_point
1111
#' @inheritParams position_jitter

R/geom-linerange.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ GeomLinerange <- ggproto(
4444
#'
4545
#' @eval rd_orientation()
4646
#'
47-
#' @eval rd_aesthetics("geom", "linerange", "Note that `geom_pointrange()` also understands `size` for the size of the points.")
47+
#' @aesthetics GeomLinerange
48+
#' Note that `geom_pointrange()` also understands `size` for the size of the points.
4849
#' @param fatten `r lifecycle::badge("deprecated")` A multiplicative factor
4950
#' used to increase the size of the middle bar in `geom_crossbar()` and the
5051
#' middle point in `geom_pointrange()`.

R/geom-map.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ NULL
99
#' it can be used in conjunction with `geom_sf()` layers and/or
1010
#' [`coord_sf()`] (see examples).
1111
#'
12-
#' @eval rd_aesthetics("geom", "map")
12+
#' @aesthetics GeomMap
1313
#' @export
1414
#' @param map Data frame that contains the map coordinates. This will
1515
#' typically be created using [fortify()] on a spatial object.

R/geom-path.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ GeomStep <- ggproto(
180180
#'
181181
#' @eval rd_orientation()
182182
#'
183-
#' @eval rd_aesthetics("geom", "path")
183+
#' @aesthetics GeomPath
184184
#' @inheritParams layer
185185
#' @inheritParams geom_bar
186186
#' @param lineend Line end style (round, butt, square).

R/geom-point.R

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ GeomPoint <- ggproto(
6565
#' `geom_point(alpha = 0.05)`) or very small (e.g.
6666
#' `geom_point(shape = ".")`).
6767
#'
68-
#' @eval rd_aesthetics("geom", "point", "The `fill` aesthetic only applies to shapes 21-25.")
68+
#' @aesthetics GeomPoint
69+
#' The `fill` aesthetic only applies to shapes 21-25.
6970
#' @inheritParams layer
7071
#' @param na.rm If `FALSE`, the default, missing values are removed with
7172
#' a warning. If `TRUE`, missing values are silently removed.

R/geom-polygon.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ GeomPolygon <- ggproto("GeomPolygon", Geom,
103103
#' differentiates the outer ring points from those describing holes in the
104104
#' polygon.
105105
#'
106-
#' @eval rd_aesthetics("geom", "polygon")
106+
#' @aesthetics GeomPolygon
107107
#' @seealso
108108
#' [geom_path()] for an unfilled polygon,
109109
#' [geom_ribbon()] for a polygon anchored on the x-axis

R/geom-quantile.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ GeomQuantile <- ggproto(
1616
#' This fits a quantile regression to the data and draws the fitted quantiles
1717
#' with lines. This is as a continuous analogue to [geom_boxplot()].
1818
#'
19-
#' @eval rd_aesthetics("geom", "quantile")
19+
#' @aesthetics GeomQuantile
2020
#' @export
2121
#' @inheritParams layer
2222
#' @inheritParams geom_point

R/geom-ribbon.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ GeomArea <- ggproto("GeomArea", GeomRibbon,
238238
#'
239239
#' @eval rd_orientation()
240240
#'
241-
#' @eval rd_aesthetics("geom", "ribbon")
241+
#' @aesthetics GeomRibbon
242242
#' @seealso
243243
#' [geom_bar()] for discrete intervals (bars),
244244
#' [geom_linerange()] for discrete intervals (lines),

R/geom-rug.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ GeomRug <- ggproto("GeomRug", Geom,
132132
#' variables is 5% at both ends of the scale, the rug will not overlap with
133133
#' any data points under the default settings.
134134
#'
135-
#' @eval rd_aesthetics("geom", "rug")
135+
#' @aesthetics GeomRug
136136
#' @inheritParams layer
137137
#' @inheritParams geom_point
138138
#' @param sides A string that controls which sides of the plot the rugs appear on.

R/geom-segment.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ GeomSegment <- ggproto(
6464
#' Both geoms draw a single segment/curve per case. See `geom_path()` if you
6565
#' need to connect points across multiple cases.
6666
#'
67-
#' @eval rd_aesthetics("geom", "segment")
67+
#' @aesthetics GeomSegment
6868
#' @inheritParams layer
6969
#' @inheritParams geom_point
7070
#' @param arrow specification for arrow heads, as created by [grid::arrow()].

R/geom-smooth.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ GeomSmooth <- ggproto(
7676
#'
7777
#' @eval rd_orientation()
7878
#'
79-
#' @eval rd_aesthetics("geom", "smooth")
79+
#' @aesthetics GeomSmooth
8080
#' @inheritParams layer
8181
#' @inheritParams geom_bar
8282
#' @param geom,stat Use to override the default connection between

R/geom-spoke.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ GeomSpoke <- ggproto(
2222
#' useful when you have variables that describe direction and distance.
2323
#' The angles start from east and increase counterclockwise.
2424
#'
25-
#' @eval rd_aesthetics("geom", "spoke")
25+
#' @aesthetics GeomSpoke
2626
#' @inheritParams layer
2727
#' @inheritParams geom_segment
2828
#' @export

R/geom-text.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ GeomText <- ggproto(
7575
#' \href{https://cran.r-project.org/package=ggrepel}{ggrepel}
7676
#' package.
7777
#'
78-
#' @eval rd_aesthetics("geom", "text")
78+
#' @aesthetics GeomText
7979
#' @section `geom_label()`:
8080
#' Currently `geom_label()` does not support the `check_overlap` argument. Also,
8181
#' it is considerably slower than `geom_text()`. The `fill` aesthetic controls

R/geom-tile.R

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@ GeomTile <- ggproto(
5454
#' `geom_raster()` is a high performance special case for when all the tiles
5555
#' are the same size, and no pattern fills are applied.
5656
#'
57-
#' @eval rd_aesthetics(
58-
#' "geom", "rect",
59-
#' "`geom_tile()` understands only the `x`/`width` and `y`/`height` combinations.
60-
#' Note that `geom_raster()` ignores `colour`."
61-
#' )
57+
#' @aesthetics GeomRect
58+
#' `geom_tile()` understands only the `x`/`width` and `y`/`height` combinations.
59+
#' Note that `geom_raster()` ignores `colour`.
6260
#' @inheritParams layer
6361
#' @inheritParams geom_point
6462
#' @inheritParams geom_segment

R/geom-violin.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#'
88
#' @eval rd_orientation()
99
#'
10-
#' @eval rd_aesthetics("geom", "violin")
10+
#' @aesthetics GeomViolin
1111
#' @inheritParams layer
1212
#' @inheritParams geom_bar
1313
#' @param trim If `TRUE` (default), trim the tails of the violins

R/position-dodge.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#' @param reverse If `TRUE`, will reverse the default stacking order.
2020
#' This is useful if you're rotating both the plot and legend.
2121
#' @family position adjustments
22-
#' @eval rd_aesthetics("position", "dodge")
22+
#' @aesthetics PositionDodge
2323
#'
2424
#' @export
2525
#' @examples

R/position-nudge.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#' @family position adjustments
99
#' @param x,y Amount of vertical and horizontal distance to move.
1010
#' @export
11-
#' @eval rd_aesthetics("position", "nudge")
11+
#' @aesthetics PositionNudge
1212
#' @examples
1313
#' df <- data.frame(
1414
#' x = c(1,3,2,5),

R/stat-connect.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ StatConnect <- ggproto(
119119
#' at location (0, 0) and point B at location (1, 1). At least one of these
120120
#' two points is expected to be included in the coordinates.
121121
#'
122-
#' @eval rd_aesthetics("stat", "connect")
122+
#' @aesthetics StatConnect
123123
#' @export
124124
#'
125125
#' @examples

R/stat-contour.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ StatContourFilled <- ggproto(
8787
#' @inheritParams stat_identity
8888
#' @inheritParams geom_contour
8989
#' @export
90-
#' @eval rd_aesthetics("stat", "contour")
91-
#' @eval rd_aesthetics("stat", "contour_filled")
90+
#' @aesthetics StatContour
91+
#' @aesthetics StatContourFilled
9292
#' @eval rd_computed_vars(
9393
#' .details = "The computed variables differ somewhat for contour lines
9494
#' (computed by `stat_contour()`) and contour bands (filled contours,

R/stat-ecdf.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ StatEcdf <- ggproto(
7373
#' of points to interpolate with.
7474
#' @param pad If `TRUE`, pad the ecdf with additional points (-Inf, 0)
7575
#' and (Inf, 1)
76-
#' @eval rd_aesthetics("stat", "ecdf")
76+
#' @aesthetics StatEcdf
7777
#' @eval rd_computed_vars(
7878
#' ecdf = "Cumulative density corresponding to `x`.",
7979
#' y = "`r lifecycle::badge('superseded')` For backward compatibility."

R/stat-ellipse.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ StatEllipse <- ggproto(
4545
#' @param segments The number of segments to be used in drawing the ellipse.
4646
#' @inheritParams layer
4747
#' @inheritParams geom_point
48-
#' @eval rd_aesthetics("stat", "ellipse")
48+
#' @aesthetics StatEllipse
4949
#' @export
5050
#' @examples
5151
#' ggplot(faithful, aes(waiting, eruptions)) +

R/stat-manual.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ StatManual <- ggproto(
2828
#' the data unchanged.
2929
#' @param args A list of arguments to pass to the function given in `fun`.
3030
#'
31-
#' @eval rd_aesthetics("stat", "manual")
31+
#' @aesthetics StatManual
3232
#' @section Aesthetics:
3333
#' Input aesthetics are determined by the `fun` argument. Output aesthetics must
3434
#' include those required by `geom`. Any aesthetic that is constant within a

R/stat-qq.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ StatQq <- ggproto(
3434
#' `stat_qq_line()` compute the slope and intercept of the line connecting the
3535
#' points at specified quartiles of the theoretical and sample distributions.
3636
#'
37-
#' @eval rd_aesthetics("stat", "qq")
38-
#' @eval rd_aesthetics("stat", "qq_line")
37+
#' @aesthetics StatQq
38+
#' @aesthetics StatQqLine
3939
#' @param distribution Distribution function to use, if x not specified
4040
#' @param dparams Additional parameters passed on to `distribution`
4141
#' function.

R/stat-summary.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#'
88
#' @eval rd_orientation()
99
#'
10-
#' @eval rd_aesthetics("stat", "summary")
10+
#' @aesthetics StatSummary
1111
#' @seealso [geom_errorbar()], [geom_pointrange()],
1212
#' [geom_linerange()], [geom_crossbar()] for geoms to
1313
#' display summarised data

R/stat-unique.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ StatUnique <- ggproto(
99

1010
#' Remove duplicates
1111
#'
12-
#' @eval rd_aesthetics("stat", "unique")
12+
#' @aesthetics StatUnique
1313
#' @export
1414
#' @inheritParams layer
1515
#' @inheritParams geom_point

0 commit comments

Comments
 (0)