Skip to content

Commit 142de17

Browse files
committed
move docs to docs_layer.R
1 parent cd6bff1 commit 142de17

File tree

3 files changed

+144
-142
lines changed

3 files changed

+144
-142
lines changed

R/docs_layer.R

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,146 @@
1+
# Shared parameters -------------------------------------------------------
2+
3+
#' @name shared_layer_parameters
4+
#' @title Shared layer parameters
5+
#' @description
6+
#' This is a central place for describing typical layer parameters.
7+
#' It prevents cluttered definitions all over the place.
8+
#'
9+
#' @param mapping
10+
#' Set of aesthetic mappings created by [aes()]. If specified and `inherit.aes =
11+
#' TRUE` (the default), it is combined with the default mapping at the top level
12+
#' of the plot. You must supply `mapping` if there is no plot mapping.
13+
#'
14+
#' @param data
15+
#' The data to be displayed in this layer. There are three options:
16+
#' * `NULL` (default): the data is inherited from the plot data as specified
17+
#' in the call to [ggplot()].
18+
#' * A `data.frame`, or other object, will override the plot data. All objects
19+
#' will be fortified to produce a data frame. See [fortify()] for which
20+
#' variables will be created.
21+
#' * A `function` will be called with a single argument, the plot data. The return
22+
#' value must be a `data.frame`, and will be used as the layer data. A
23+
#' `function` can be created from a `formula` (e.g. `~ head(.x, 10)`).
24+
#'
25+
#' @param geom
26+
#' The geometric object to use to display the data for this layer. When using a
27+
#' `stat_*()` function to construct a layer, the `geom` argument can be used to
28+
#' override the default coupling between stats and geoms. The `geom` argument
29+
#' accepts the following:
30+
#' * A `Geom` ggproto subclass, for example `GeomPoint`.
31+
#' * A string naming the geom. To give the geom as a string, strip the
32+
#' function name of the `geom_` prefix. For example, to use `geom_point()`,
33+
#' give the geom as `"point"`.
34+
#' * For more information and other ways to specify the geom, see the
35+
#' [layer geom][layer_geoms] documentation.
36+
#'
37+
#' @param stat
38+
#' The statistical transformation to use on the data for this layer. When using
39+
#' a `geom_*()` function to construct a layer, the `stat` argument can be used
40+
#' to override the default coupling between geoms and stats. The `stat` argument
41+
#' accepts the following:
42+
#' * A `Stat` ggproto subclass, for example `StatCount`.
43+
#' * A string naming the stat. To give the stat as a string, strip the
44+
#' function name of the `stat_` prefix. For example, to use `stat_count()`,
45+
#' give the stat as `"count"`.
46+
#' * For more information and other ways to specify the stat, see the
47+
#' [layer stat][layer_stats] documentation.
48+
#'
49+
#' @param position
50+
#' A position adjustment to use on the data for this layer. This can be used in
51+
#' various ways, including to prevent overplotting and improving the display.
52+
#' The `position` argument accepts the following:
53+
#' * The result of calling a position function, such as `position_jitter()`.
54+
#' This method allows for passing extra arguments to the position.
55+
#' * A string naming the position adjustment. To give the position as a
56+
#' string, strip the function name of the `position_` prefix. For example, to
57+
#' use `position_jitter()`, give the position as `"jitter"`.
58+
#' * For more information and other ways to specify the position, see the
59+
#' [layer position][layer_positions] documentation.
60+
#'
61+
#' @param na.rm
62+
#' If `FALSE`, the default, missing values are removed with a warning. If
63+
#' `TRUE`, missing values are silently removed.
64+
#'
65+
#' @param show.legend
66+
#' Logical. Should this layer be included in the legends? `NA`, the default,
67+
#' includes if any aesthetics are mapped. `FALSE` never includes, and `TRUE`
68+
#' always includes. It can also be a named logical vector to finely select the
69+
#' aesthetics to display. To include legend keys for all levels, even when no
70+
#' data exists, use `TRUE`. If `NA`, all levels are shown in legend, but
71+
#' unobserved levels are omitted.
72+
#'
73+
#' @param inherit.aes
74+
#' If `FALSE`, overrides the default aesthetics, rather than combining with
75+
#' them. This is most useful for helper functions that define both data and
76+
#' aesthetics and shouldn't inherit behaviour from the default plot
77+
#' specification, e.g. [annotation_borders()].
78+
#'
79+
#' @param ...
80+
#' Other arguments passed on to [layer()]'s `params` argument. These arguments
81+
#' broadly fall into one of 4 categories below. Notably, further arguments to
82+
#' the `position` argument, or aesthetics that are required can
83+
#' *not* be passed through `...`. Unknown arguments that are not part of the 4
84+
#' categories below are ignored.
85+
#' * Static aesthetics that are not mapped to a scale, but are at a fixed
86+
#' value and apply to the layer as a whole. For example, `colour = "red"` or
87+
#' `linewidth = 3`. The geom's documentation has an **Aesthetics** section
88+
#' that lists the available options. The 'required' aesthetics cannot be
89+
#' passed on to the `params`. Please note that while passing unmapped
90+
#' aesthetics as vectors is technically possible, the order and required
91+
#' length is not guaranteed to be parallel to the input data.
92+
#' * When constructing a layer using
93+
#' a `stat_*()` function, the `...` argument can be used to pass on parameters
94+
#' to the `geom` part of the layer. An example of this is
95+
#' `stat_density(geom = "area", outline.type = "both")`. The geom's
96+
#' documentation lists which parameters it can accept.
97+
#' * Inversely, when constructing a layer using a
98+
#' `geom_*()` function, the `...` argument can be used to pass on parameters
99+
#' to the `stat` part of the layer. An example of this is
100+
#' `geom_area(stat = "density", adjust = 0.5)`. The stat's documentation lists
101+
#' which parameters it can accept.
102+
#' * The `key_glyph` argument of [`layer()`] may also be passed on through
103+
#' `...`. This can be one of the functions described as
104+
#' [key glyphs][draw_key], to change the display of the layer in the legend.
105+
#'
106+
#' @param lineend
107+
#' Line end style, one of `"round"`, `"butt"` or `"square"`.
108+
#'
109+
#' @param linejoin
110+
#' Line join style, one of `"round"`, `"mitre"` or `"bevel"`.
111+
#'
112+
#' @param linemitre
113+
#' Line mitre limit, a number greater than 1.
114+
#'
115+
#' @param arrow
116+
#' Arrow specification. Can be created by [grid::arrow()] or `NULL` to not draw
117+
#' an arrow.
118+
#'
119+
#' @param arrow.fill
120+
#' Fill colour to use for closed arrowheads. `NULL` means use `colour`
121+
#' aesthetic.
122+
#'
123+
#' @param orientation
124+
#' The orientation of the layer. The default (`NA`) automatically determines the
125+
#' orientation from the aesthetic mapping. In the rare event that this fails it
126+
#' can be given explicitly by setting `orientation` to either `"x"` or `"y"`.
127+
#' See the *Orientation* section for more detail.
128+
#'
129+
#' @section Orientation:
130+
#' This geom treats each axis differently and, thus, can have two
131+
#' orientations. Often the orientation is easy to deduce from a combination of
132+
#' the given mappings and the types of positional scales in use. Thus, ggplot2
133+
#' will by default try to guess which orientation the layer should have. Under
134+
#' rare circumstances, the orientation is ambiguous and guessing may fail. In
135+
#' that case the orientation can be specified directly using the `orientation`
136+
#' parameter, which can be either `"x"` or `"y"`. The value gives the axis that
137+
#' the geom should run along, `"x"` being the default orientation you would
138+
#' expect for the geom.
139+
#'
140+
#' @keywords internal
141+
#' @aliases NULL
142+
NULL
143+
1144
# Geoms -------------------------------------------------------------------
2145

3146
#' @title

R/layer.R

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -1,144 +1,3 @@
1-
#' @name shared_layer_parameters
2-
#' @title Shared layer parameters
3-
#' @description
4-
#' This is a central place for describing typical layer parameters.
5-
#' It prevents cluttered definitions all over the place.
6-
#'
7-
#' @param mapping
8-
#' Set of aesthetic mappings created by [aes()]. If specified and `inherit.aes =
9-
#' TRUE` (the default), it is combined with the default mapping at the top level
10-
#' of the plot. You must supply `mapping` if there is no plot mapping.
11-
#'
12-
#' @param data
13-
#' The data to be displayed in this layer. There are three options:
14-
#' * `NULL` (default): the data is inherited from the plot data as specified
15-
#' in the call to [ggplot()].
16-
#' * A `data.frame`, or other object, will override the plot data. All objects
17-
#' will be fortified to produce a data frame. See [fortify()] for which
18-
#' variables will be created.
19-
#' * A `function` will be called with a single argument, the plot data. The return
20-
#' value must be a `data.frame`, and will be used as the layer data. A
21-
#' `function` can be created from a `formula` (e.g. `~ head(.x, 10)`).
22-
#'
23-
#' @param geom
24-
#' The geometric object to use to display the data for this layer. When using a
25-
#' `stat_*()` function to construct a layer, the `geom` argument can be used to
26-
#' override the default coupling between stats and geoms. The `geom` argument
27-
#' accepts the following:
28-
#' * A `Geom` ggproto subclass, for example `GeomPoint`.
29-
#' * A string naming the geom. To give the geom as a string, strip the
30-
#' function name of the `geom_` prefix. For example, to use `geom_point()`,
31-
#' give the geom as `"point"`.
32-
#' * For more information and other ways to specify the geom, see the
33-
#' [layer geom][layer_geoms] documentation.
34-
#'
35-
#' @param stat
36-
#' The statistical transformation to use on the data for this layer. When using
37-
#' a `geom_*()` function to construct a layer, the `stat` argument can be used
38-
#' to override the default coupling between geoms and stats. The `stat` argument
39-
#' accepts the following:
40-
#' * A `Stat` ggproto subclass, for example `StatCount`.
41-
#' * A string naming the stat. To give the stat as a string, strip the
42-
#' function name of the `stat_` prefix. For example, to use `stat_count()`,
43-
#' give the stat as `"count"`.
44-
#' * For more information and other ways to specify the stat, see the
45-
#' [layer stat][layer_stats] documentation.
46-
#'
47-
#' @param position
48-
#' A position adjustment to use on the data for this layer. This can be used in
49-
#' various ways, including to prevent overplotting and improving the display.
50-
#' The `position` argument accepts the following:
51-
#' * The result of calling a position function, such as `position_jitter()`.
52-
#' This method allows for passing extra arguments to the position.
53-
#' * A string naming the position adjustment. To give the position as a
54-
#' string, strip the function name of the `position_` prefix. For example, to
55-
#' use `position_jitter()`, give the position as `"jitter"`.
56-
#' * For more information and other ways to specify the position, see the
57-
#' [layer position][layer_positions] documentation.
58-
#'
59-
#' @param na.rm
60-
#' If `FALSE`, the default, missing values are removed with a warning. If
61-
#' `TRUE`, missing values are silently removed.
62-
#'
63-
#' @param show.legend
64-
#' Logical. Should this layer be included in the legends? `NA`, the default,
65-
#' includes if any aesthetics are mapped. `FALSE` never includes, and `TRUE`
66-
#' always includes. It can also be a named logical vector to finely select the
67-
#' aesthetics to display. To include legend keys for all levels, even when no
68-
#' data exists, use `TRUE`. If `NA`, all levels are shown in legend, but
69-
#' unobserved levels are omitted.
70-
#'
71-
#' @param inherit.aes
72-
#' If `FALSE`, overrides the default aesthetics, rather than combining with
73-
#' them. This is most useful for helper functions that define both data and
74-
#' aesthetics and shouldn't inherit behaviour from the default plot
75-
#' specification, e.g. [annotation_borders()].
76-
#'
77-
#' @param ...
78-
#' Other arguments passed on to [layer()]'s `params` argument. These arguments
79-
#' broadly fall into one of 4 categories below. Notably, further arguments to
80-
#' the `position` argument, or aesthetics that are required can
81-
#' *not* be passed through `...`. Unknown arguments that are not part of the 4
82-
#' categories below are ignored.
83-
#' * Static aesthetics that are not mapped to a scale, but are at a fixed
84-
#' value and apply to the layer as a whole. For example, `colour = "red"` or
85-
#' `linewidth = 3`. The geom's documentation has an **Aesthetics** section
86-
#' that lists the available options. The 'required' aesthetics cannot be
87-
#' passed on to the `params`. Please note that while passing unmapped
88-
#' aesthetics as vectors is technically possible, the order and required
89-
#' length is not guaranteed to be parallel to the input data.
90-
#' * When constructing a layer using
91-
#' a `stat_*()` function, the `...` argument can be used to pass on parameters
92-
#' to the `geom` part of the layer. An example of this is
93-
#' `stat_density(geom = "area", outline.type = "both")`. The geom's
94-
#' documentation lists which parameters it can accept.
95-
#' * Inversely, when constructing a layer using a
96-
#' `geom_*()` function, the `...` argument can be used to pass on parameters
97-
#' to the `stat` part of the layer. An example of this is
98-
#' `geom_area(stat = "density", adjust = 0.5)`. The stat's documentation lists
99-
#' which parameters it can accept.
100-
#' * The `key_glyph` argument of [`layer()`] may also be passed on through
101-
#' `...`. This can be one of the functions described as
102-
#' [key glyphs][draw_key], to change the display of the layer in the legend.
103-
#'
104-
#' @param lineend
105-
#' Line end style, one of `"round"`, `"butt"` or `"square"`.
106-
#'
107-
#' @param linejoin
108-
#' Line join style, one of `"round"`, `"mitre"` or `"bevel"`.
109-
#'
110-
#' @param linemitre
111-
#' Line mitre limit, a number greater than 1.
112-
#'
113-
#' @param arrow
114-
#' Arrow specification. Can be created by [grid::arrow()] or `NULL` to not draw
115-
#' an arrow.
116-
#'
117-
#' @param arrow.fill
118-
#' Fill colour to use for closed arrowheads. `NULL` means use `colour`
119-
#' aesthetic.
120-
#'
121-
#' @param orientation
122-
#' The orientation of the layer. The default (`NA`) automatically determines the
123-
#' orientation from the aesthetic mapping. In the rare event that this fails it
124-
#' can be given explicitly by setting `orientation` to either `"x"` or `"y"`.
125-
#' See the *Orientation* section for more detail.
126-
#'
127-
#' @section Orientation:
128-
#' This geom treats each axis differently and, thus, can have two
129-
#' orientations. Often the orientation is easy to deduce from a combination of
130-
#' the given mappings and the types of positional scales in use. Thus, ggplot2
131-
#' will by default try to guess which orientation the layer should have. Under
132-
#' rare circumstances, the orientation is ambiguous and guessing may fail. In
133-
#' that case the orientation can be specified directly using the `orientation`
134-
#' parameter, which can be either `"x"` or `"y"`. The value gives the axis that
135-
#' the geom should run along, `"x"` being the default orientation you would
136-
#' expect for the geom.
137-
#'
138-
#' @keywords internal
139-
#' @aliases NULL
140-
NULL
141-
1421
#' Create a new layer
1432
#'
1443
#' A layer is a combination of data, stat and geom with a potential position

man/shared_layer_parameters.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)