Skip to content

Commit dc09b97

Browse files
authored
Merge branch 'main' into rename_coord_transform
2 parents b88da1d + 5971ff4 commit dc09b97

File tree

129 files changed

+1067
-591
lines changed

Some content is hidden

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

129 files changed

+1067
-591
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,9 @@ Imports:
3939
isoband,
4040
lifecycle (> 1.0.1),
4141
MASS,
42-
mgcv,
4342
rlang (>= 1.1.0),
4443
scales (>= 1.3.0),
4544
stats,
46-
tibble,
4745
vctrs (>= 0.6.0),
4846
withr (>= 2.5.0)
4947
Suggests:
@@ -55,6 +53,7 @@ Suggests:
5553
knitr,
5654
mapproj,
5755
maps,
56+
mgcv,
5857
multcomp,
5958
munsell,
6059
nlme,
@@ -67,6 +66,7 @@ Suggests:
6766
sf (>= 0.7-3),
6867
svglite (>= 2.1.2),
6968
testthat (>= 3.1.5),
69+
tibble,
7070
vdiffr (>= 1.0.6),
7171
xml2
7272
Enhances:

NAMESPACE

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,8 @@ export(remove_missing)
515515
export(render_axes)
516516
export(render_strips)
517517
export(replace_theme)
518+
export(reset_geom_defaults)
519+
export(reset_stat_defaults)
518520
export(reset_theme_settings)
519521
export(resolution)
520522
export(scale_alpha)
@@ -735,7 +737,6 @@ importFrom(grid,unit)
735737
importFrom(lifecycle,deprecated)
736738
importFrom(scales,alpha)
737739
importFrom(stats,setNames)
738-
importFrom(tibble,tibble)
739740
importFrom(utils,.DollarNames)
740741
importFrom(utils,head)
741742
importFrom(utils,tail)

R/annotation-logticks.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
165165

166166
names(xticks)[names(xticks) == "value"] <- x_name # Rename to 'x' for coordinates$transform
167167
xticks <- coord$transform(xticks, panel_params)
168-
xticks = xticks[xticks$x <= 1 & xticks$x >= 0,]
168+
xticks <- xticks[xticks$x <= 1 & xticks$x >= 0,]
169169

170170
if (outside)
171171
xticks$end = -xticks$end
@@ -203,7 +203,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
203203

204204
names(yticks)[names(yticks) == "value"] <- y_name # Rename to 'y' for coordinates$transform
205205
yticks <- coord$transform(yticks, panel_params)
206-
yticks = yticks[yticks$y <= 1 & yticks$y >= 0,]
206+
yticks <- yticks[yticks$y <= 1 & yticks$y >= 0,]
207207

208208
if (outside)
209209
yticks$end = -yticks$end
@@ -238,7 +238,7 @@ GeomLogticks <- ggproto("GeomLogticks", Geom,
238238
# - start: on the other axis, start position of the line (usually 0)
239239
# - end: on the other axis, end position of the line (for example, .1, .2, or .3)
240240
calc_logticks <- function(base = 10, ticks_per_base = base - 1,
241-
minpow = 0, maxpow = minpow + 1, start = 0, shortend = .1, midend = .2, longend = .3) {
241+
minpow = 0, maxpow = minpow + 1, start = 0, shortend = 0.1, midend = 0.2, longend = 0.3) {
242242

243243
# Number of blocks of tick marks
244244
reps <- maxpow - minpow

R/axis-secondary.R

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,13 @@ AxisSecondary <- ggproto("AxisSecondary", NULL,
188188
if (scale$is_discrete()) {
189189
self$breaks <- scale$get_breaks()
190190
} else {
191-
self$breaks <- scale$get_transformation()$breaks
191+
breaks <- scale$get_transformation()$breaks
192+
n_breaks <- scale$n.breaks
193+
if (!is.null(n_breaks) && "n" %in% fn_fmls_names(breaks)) {
194+
self$breaks <- function(x) breaks(x, n = n_breaks)
195+
} else {
196+
self$breaks <- breaks
197+
}
192198
}
193199
}
194200
if (is.derived(self$labels)) self$labels <- scale$labels

R/bin.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ bin_vector <- function(x, bins, weight = NULL, pad = FALSE) {
165165
}
166166

167167
# Add row for missings
168-
if (any(is.na(bins))) {
168+
if (anyNA(bins)) {
169169
bin_count <- c(bin_count, sum(is.na(bins)))
170170
bin_widths <- c(bin_widths, NA)
171171
bin_x <- c(bin_x, NA)

R/compat-plyr.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ rename <- function(x, replace) {
5454
id_var <- function(x, drop = FALSE) {
5555
if (length(x) == 0) {
5656
id <- integer()
57-
n = 0L
57+
n <- 0L
5858
} else if (!is.null(attr(x, "n")) && !drop) {
5959
return(x)
6060
} else if (is.factor(x) && !drop) {
6161
x <- addNA(x, ifany = TRUE)
6262
id <- as.integer(x)
63-
n <- length(levels(x))
63+
n <- nlevels(x)
6464
} else {
6565
levels <- sort(unique0(x), na.last = TRUE)
6666
id <- match(x, levels)

R/coord-.R

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ Coord <- ggproto("Coord",
208208
# used as a fudge for CoordFlip and CoordPolar
209209
modify_scales = function(scales_x, scales_y) {
210210
invisible()
211+
},
212+
213+
draw_panel = function(self, panel, params, theme) {
214+
fg <- self$render_fg(params, theme)
215+
bg <- self$render_bg(params, theme)
216+
if (isTRUE(theme$panel.ontop)) {
217+
panel <- list2(!!!panel, bg, fg)
218+
} else {
219+
panel <- list2(bg, !!!panel, fg)
220+
}
221+
gTree(
222+
children = inject(gList(!!!panel)),
223+
vp = viewport(clip = self$clip)
224+
)
211225
}
212226
)
213227

R/coord-polar.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ CoordPolar <- ggproto("CoordPolar", Coord,
137137
ret[[n]]$sec.labels <- out$sec.labels
138138
}
139139

140-
details = list(
140+
details <- list(
141141
x.range = ret$x$range, y.range = ret$y$range,
142142
x.major = ret$x$major, y.major = ret$y$major,
143143
x.minor = ret$x$minor, y.minor = ret$y$minor,

R/coord-radial.R

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,27 @@ CoordRadial <- ggproto("CoordRadial", Coord,
409409
)
410410
},
411411

412+
413+
draw_panel = function(self, panel, params, theme) {
414+
clip_support <- check_device("clippingPaths", "test", maybe = TRUE)
415+
if (self$clip == "on" && !isFALSE(clip_support)) {
416+
clip_path <- data_frame0(
417+
x = c(Inf, Inf, -Inf, -Inf),
418+
y = c(Inf, -Inf, -Inf, Inf)
419+
)
420+
clip_path <- coord_munch(self, clip_path, params, is_closed = TRUE)
421+
clip_path <- polygonGrob(clip_path$x, clip_path$y)
422+
# Note that clipping path is applied to panel without coord
423+
# foreground/background (added in parent method).
424+
# These may contain decorations that needn't be clipped
425+
panel <- list(gTree(
426+
children = inject(gList(!!!panel)),
427+
vp = viewport(clip = clip_path)
428+
))
429+
}
430+
ggproto_parent(Coord, self)$draw_panel(panel, params, theme)
431+
},
432+
412433
labels = function(self, labels, panel_params) {
413434
# `Layout$resolve_label()` doesn't know to look for theta/r/r.sec guides,
414435
# so we'll handle title propagation here.

R/coord-sf.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ sf_rescale01 <- function(x, x_range, y_range) {
416416

417417
# different limits methods
418418
calc_limits_bbox <- function(method, xlim, ylim, crs, default_crs) {
419-
if (any(!is.finite(c(xlim, ylim))) && method != "geometry_bbox") {
419+
if (!all(is.finite(c(xlim, ylim))) && method != "geometry_bbox") {
420420
cli::cli_abort(c(
421421
"Scale limits cannot be mapped onto spatial coordinates in {.fn coord_sf}.",
422422
"i" = "Consider setting {.code lims_method = \"geometry_bbox\"} or {.code default_crs = NULL}."
@@ -585,7 +585,7 @@ coord_sf <- function(xlim = NULL, ylim = NULL, expand = TRUE,
585585
}
586586

587587
parse_axes_labeling <- function(x) {
588-
labs = unlist(strsplit(x, ""))
588+
labs <- unlist(strsplit(x, ""))
589589
list(top = labs[1], right = labs[2], bottom = labs[3], left = labs[4])
590590
}
591591

0 commit comments

Comments
 (0)