Skip to content

Commit

Permalink
tweak argument order of proj.fill
Browse files Browse the repository at this point in the history
  • Loading branch information
hughjonesd committed Feb 21, 2024
1 parent 8e80573 commit 380ff57
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion R/geom-magnify-tile.R
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ geom_magnify_tile <- function (mapping = NULL,
proj.linetype = 2,
alpha = 1,
linewidth = 0.4,
proj.fill = NULL,
plot = NULL,
shadow.args = list(sigma = 5, colour = "grey40",
x_offset = 5, y_offset = 5),
recompute = FALSE,
scale.inset = 1,
proj.combine = TRUE,
proj.fill = NULL,
na.rm = FALSE,
inherit.aes = FALSE) {
proj <- match.arg(proj)
Expand Down
8 changes: 4 additions & 4 deletions R/geom-magnify.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ NULL
#' for borders and projection lines.
#' @param target.linetype,inset.linetype,proj.linetype Linetypes
#' for specific components. Set to `0` for no lines.
#' @param proj.fill Colour to fill between the projection lines. `NULL` for no
#' fill. Add alpha using e.g. [scales::alpha()]. Ignored when
#' `proj = "single"`.
#' @param plot Ggplot object to plot in the inset. If `NULL`, defaults to the
#' ggplot object to which `geom_magnify()` is added.
#' @param shadow.args List. Arguments to [ggfx::with_shadow()].
Expand All @@ -62,9 +65,6 @@ NULL
#' @param proj.combine Logical. How to draw projection lines when more than
#' one polygon/map area is magnified? `FALSE` draws one set of projection
#' lines for each area. `TRUE` draws a single set of lines for all the areas.
#' @param proj.fill `NULL` for no fill, or a colour to fill between the
#' projection lines. Add alpha using e.g. [scales::alpha()]. Ignored when
#' `proj = "single"`.
#'
#' @details
#' ## Aesthetics
Expand Down Expand Up @@ -203,13 +203,13 @@ geom_magnify <- function (mapping = NULL,
proj.linetype = 2,
alpha = 1,
linewidth = 0.4,
proj.fill = NULL,
plot = NULL,
shadow.args = list(sigma = 5, colour = "grey40",
x_offset = 5, y_offset = 5),
recompute = FALSE,
scale.inset = 1,
proj.combine = TRUE,
proj.fill = NULL,
na.rm = FALSE,
inherit.aes = TRUE) {
proj <- match.arg(proj)
Expand Down
12 changes: 6 additions & 6 deletions man/geom_magnify.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions tests/testthat/test-doctest-geom_magnify.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
test_that("Doctest: geom_magnify", {
# Created from @doctest for `geom_magnify`
# Source file: R/geom-magnify.R
# Source line: 148
# Source line: 155
library(ggplot2)
ggp <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) +
geom_point() + xlim(c(2, 6))
ggp <- ggplot(iris, aes(Sepal.Width, Sepal.Length, colour = Species)) + geom_point() +
xlim(c(2, 6))
from <- list(2.5, 3.5, 6, 7)
to <- list(4, 6, 5, 7)
expect_silent(ggp + geom_magnify(from = from, to = to))
expect_silent(ggp + geom_magnify(aes(from = Species == "setosa"), to = c(3, 5,
6, 8), shape = "outline"))
expect_silent(ggp + geom_magnify(aes(from = Species == "setosa"), to = c(3, 5, 6, 8),
shape = "outline"))
expect_silent(ggp + scale_color_brewer() + geom_magnify(from = from, to = to))
expect_no_error(ggp + geom_magnify(from = from, to = to) + scale_color_brewer())
})
Expand Down
8 changes: 3 additions & 5 deletions tests/testthat/test-doctest-grob_where.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ test_that("Doctest: grob_where", {
# Source file: R/helpers.R
# Source line: 67
library(ggplot2)
if (requireNamespace("sf", quietly = TRUE) && requireNamespace("maps", quietly = TRUE)
) {
if (requireNamespace("sf", quietly = TRUE) && requireNamespace("maps", quietly = TRUE)) {
usa <- sf::st_as_sf(maps::map("state", fill = TRUE, plot = FALSE))
expect_snapshot(texas <- grob_where(ID == "texas", usa, crs = sf::st_crs(4326)))
ggplot(usa) + coord_sf(crs = sf::st_crs(4326)) + geom_sf() + geom_magnify(
from = texas, to = c(-90, -70, 25, 35), colour = "red", aspect = "fixed",
expand = 0)
ggplot(usa) + coord_sf(crs = sf::st_crs(4326)) + geom_sf() + geom_magnify(from = texas,
to = c(-90, -70, 25, 35), colour = "red", aspect = "fixed", expand = 0)
}
})

0 comments on commit 380ff57

Please sign in to comment.