Skip to content

Commit ba166c6

Browse files
committed
collapse docs
1 parent 94574e3 commit ba166c6

19 files changed

+492
-737
lines changed

R/layout-circle-.R

Lines changed: 49 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
#' Arrange plots in a circular layout by aligning discrete axis
1+
#' Arrange plots in a circular layout
22
#'
33
#' @description
44
#' `r lifecycle::badge('experimental')`
55
#'
6-
#' The `circle_discrete` function arranges plots by aligning discrete variables
7-
#' in a circular layout.
6+
#' If `limits` is provided, a continuous variable will be required and aligned
7+
#' in the direction specified (`circle_continuous`). Otherwise, a discrete
8+
#' variable will be required and aligned (`circle_discrete`).
89
#'
9-
#' @inheritParams stack_discrete
1010
#' @param radial A [`coord_radial()`][ggplot2::coord_radial] object that defines
1111
#' the global parameters for `coord_radial` across all plots in the layout.
1212
#' The parameters `start`, `end`, `direction`, and `expand` will be inherited
@@ -17,12 +17,53 @@
1717
#' indicating the direction in which the plot is added.
1818
#' - `outward`: The plot is added from the inner to the outer.
1919
#' - `inward`: The plot is added from the outer to the inner.
20+
#' @inheritParams stack_layout
21+
#' @return A `CircleLayout` object.
2022
#' @examples
2123
#' set.seed(123)
24+
#'
2225
#' small_mat <- matrix(rnorm(56), nrow = 7)
2326
#' rownames(small_mat) <- paste0("row", seq_len(nrow(small_mat)))
2427
#' colnames(small_mat) <- paste0("column", seq_len(ncol(small_mat)))
2528
#'
29+
#' # circle_layout
30+
#' # same for circle_discrete()
31+
#' circle_layout(small_mat) +
32+
#' ggalign() +
33+
#' geom_tile(aes(y = .column_index, fill = value)) +
34+
#' scale_fill_viridis_c() +
35+
#' align_dendro(aes(color = branch), k = 3L) +
36+
#' scale_color_brewer(palette = "Dark2")
37+
#'
38+
#' # same for circle_continuous()
39+
#' circle_layout(mpg, limits = continuous_limits(c(3, 5))) +
40+
#' ggalign(mapping = aes(displ, hwy, colour = class)) +
41+
#' geom_point(size = 2) +
42+
#' ggalign(mapping = aes(displ, hwy, colour = class)) +
43+
#' geom_point(size = 2) &
44+
#' scale_color_brewer(palette = "Dark2") &
45+
#' theme_bw()
46+
#'
47+
#' @export
48+
circle_layout <- function(data = NULL, ..., radial = NULL,
49+
direction = "outward", limits = waiver(),
50+
theme = NULL) {
51+
if (is.waive(limits)) {
52+
circle_discrete(
53+
data = data, ..., radial = radial,
54+
direction = direction, theme = theme
55+
)
56+
} else {
57+
circle_continuous(
58+
data = data, ..., radial = radial,
59+
direction = direction, theme = theme, limits = limits
60+
)
61+
}
62+
}
63+
64+
############################################################
65+
#' @examples
66+
#' # circle_discrete()
2667
#' # direction outward
2768
#' circle_discrete(small_mat) +
2869
#' align_dendro(aes(color = branch), k = 3L) +
@@ -38,7 +79,9 @@
3879
#' scale_fill_viridis_c() +
3980
#' align_dendro(aes(color = branch), k = 3L) +
4081
#' scale_color_brewer(palette = "Dark2")
82+
#'
4183
#' @export
84+
#' @rdname circle_layout
4285
circle_discrete <- function(data = NULL, ..., radial = NULL,
4386
direction = "outward", theme = NULL) {
4487
UseMethod("circle_discrete", data)
@@ -81,17 +124,8 @@ circle_discrete.function <- function(data = NULL, ...) {
81124
circle_discrete.formula <- circle_discrete.function
82125

83126
################################################################
84-
#' Arrange plots in a circular layout by aligning continuous axis
85-
#'
86-
#' @description
87-
#' `r lifecycle::badge('experimental')`
88-
#'
89-
#' The `circle_continuous` function arranges plots by aligning continuous
90-
#' variables in a circular layout.
91-
#'
92-
#' @inheritParams circle_discrete
93-
#' @inheritParams stack_continuous
94127
#' @examples
128+
#' # circle_continuous()
95129
#' circle_continuous(mpg, limits = continuous_limits(c(3, 5))) +
96130
#' ggalign(mapping = aes(displ, hwy, colour = class)) +
97131
#' geom_point(size = 2) +
@@ -100,6 +134,7 @@ circle_discrete.formula <- circle_discrete.function
100134
#' scale_color_brewer(palette = "Dark2") &
101135
#' theme_bw()
102136
#' @export
137+
#' @rdname circle_layout
103138
circle_continuous <- function(data = NULL, ..., radial = NULL,
104139
direction = "outward", limits = NULL,
105140
theme = NULL) {
@@ -161,50 +196,6 @@ new_circle_layout <- function(data, design, radial, direction, schemes = NULL,
161196
)
162197
}
163198

164-
#' Arrange plots in a circular layout
165-
#'
166-
#' @description
167-
#' `r lifecycle::badge('experimental')`
168-
#'
169-
#' This function integrates the functionalities of `circle_discrete()` and
170-
#' `circle_continuous()` into a single interface.
171-
#'
172-
#' @inheritParams stack_layout
173-
#' @return A `CircleLayout` object.
174-
#' @seealso
175-
#' - [`circle_discrete()`]
176-
#' - [`circle_continuous()`]
177-
#' @examples
178-
#' set.seed(123)
179-
#'
180-
#' # circle_discrete
181-
#' small_mat <- matrix(rnorm(56), nrow = 7)
182-
#' rownames(small_mat) <- paste0("row", seq_len(nrow(small_mat)))
183-
#' colnames(small_mat) <- paste0("column", seq_len(ncol(small_mat)))
184-
#' circle_layout(small_mat) +
185-
#' ggalign() +
186-
#' geom_tile(aes(y = .column_index, fill = value)) +
187-
#' scale_fill_viridis_c() +
188-
#' align_dendro(aes(color = branch), k = 3L) +
189-
#' scale_color_brewer(palette = "Dark2")
190-
#'
191-
#' # circle_continuous
192-
#' circle_layout(mpg, limits = continuous_limits(c(3, 5))) +
193-
#' ggalign(mapping = aes(displ, hwy, colour = class)) +
194-
#' geom_point(size = 2) +
195-
#' ggalign(mapping = aes(displ, hwy, colour = class)) +
196-
#' geom_point(size = 2) &
197-
#' scale_color_brewer(palette = "Dark2") &
198-
#' theme_bw()
199-
#' @export
200-
circle_layout <- function(data = NULL, ..., limits = waiver()) {
201-
if (is.waive(limits)) {
202-
circle_discrete(data = data, ...)
203-
} else {
204-
circle_continuous(data = data, limits = limits, ...)
205-
}
206-
}
207-
208199
############################################################
209200
# Used to place multiple objects in one axis
210201
#' @importFrom grid unit

R/layout-heatmap-.R

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@
99
#' visualization layers are automatically applied. `ggheatmap` is an alias for
1010
#' `heatmap_layout`.
1111
#'
12-
#' @inheritParams quad_discrete
12+
#' @param data `r rd_layout_data()`. By default, it will try to inherit from
13+
#' parent layout. [`fortify_matrix()`] will be used to convert data to a
14+
#' matrix.
15+
#' @param ... Additional arguments passed to [`fortify_matrix()`].
16+
#' @inheritParams quad_layout
1317
#' @param filling A single string of `r oxford_or(c("raster", "tile"))` to
1418
#' indicate the filling style. By default, `waiver()` is used, which means that
1519
#' if the input matrix has more than 20,000 cells (`nrow * ncol > 20000`),
@@ -32,7 +36,25 @@
3236
#' [`scale_fill_discrete()`][ggplot2::scale_fill_discrete] for details on
3337
#' option settings.
3438
#'
35-
#' @inheritSection quad_discrete ggplot2 specification
39+
#' @section ggplot2 specification:
40+
#' The data input will be converted to a matrix using [`fortify_matrix()`], and
41+
#' the data in the underlying main plot will contain the following columns:
42+
#'
43+
#' - `.panel_x` and `.panel_y`: the column and row panel groups.
44+
#'
45+
#' - `.x` and `.y`: an integer index of `x` and `y` coordinates
46+
#'
47+
#' - `.discrete_x` and `.discrete_y`: a factor of the data labels (only
48+
#' applicable when `.row_names` and `.column_names` exists).
49+
#'
50+
#' - `.row_names` and `.column_names`: A character of the row and column names
51+
#' of the original matrix (only applicable when names exist).
52+
#'
53+
#' - `.row_index` and `.column_index`: the row and column index of the original
54+
#' matrix.
55+
#'
56+
#' - `value`: the actual matrix value.
57+
#'
3658
#' @return A `HeatmapLayout` object.
3759
#' @examples
3860
#' ggheatmap(1:10)

0 commit comments

Comments
 (0)