Skip to content

Commit 0017b98

Browse files
committed
insert gggenomes_layout directly into ggplot data slot - no need to reconstruct/fortify. Ensures ggplot 4.0.0 compatibility. Fixes #217, #220, #224
1 parent 5af63b6 commit 0017b98

File tree

2 files changed

+2
-45
lines changed

2 files changed

+2
-45
lines changed

R/gggenomes.R

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ gggenomes <- function(
141141
infer_end = {{ infer_end }}, infer_length = {{ infer_length }}, ...
142142
)
143143

144-
p <- ggplot(data = layout)
144+
p <- ggplot()
145+
p$data <- layout
145146
class(p) <- c("gggenomes", class(p))
146147

147148
p <- p + scale_y_continuous(expand = expansion(add = .7, mult = 0.01))
@@ -157,35 +158,6 @@ gggenomes <- function(
157158
p
158159
}
159160

160-
#' ggplot.default tries to `fortify(data)` and we don't want that here
161-
#'
162-
#' @export
163-
#' @return ggplot object
164-
#' @keywords internal
165-
ggplot.gggenomes_layout <- function(data, mapping = aes(), ...,
166-
environment = parent.frame()) {
167-
if (!missing(mapping) && !inherits(mapping, "uneval")) {
168-
stop("Mapping should be created with `aes() or `aes_()`.", call. = FALSE)
169-
}
170-
171-
p <- structure(list(
172-
data = data,
173-
layers = list(),
174-
scales = ggplot2__scales_list(),
175-
guides = ggplot2__guides_list(),
176-
mapping = mapping,
177-
theme = list(),
178-
coordinates = coord_cartesian(default = TRUE),
179-
facet = facet_null(),
180-
plot_env = environment,
181-
layout = ggplot2::ggproto(NULL, Layout)
182-
), class = c("gg", "ggplot"))
183-
184-
p$labels <- ggplot2__make_labels(mapping)
185-
186-
ggplot2::set_last_plot(p)
187-
p
188-
}
189161
#' Layout genomes
190162
#' @inheritParams gggenomes
191163
#' @keywords internal

man/ggplot.gggenomes_layout.Rd

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)