Skip to content

Commit 05f63cd

Browse files
committed
Absorb arguments meant for grDevices devices in ragg devices and throw a warning instead of errorring
1 parent 99bc8c8 commit 05f63cd

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

NEWS.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
# ggplot2 (development version)
22

33
* Revert changes made in #4434 (apply transform to intercept in `geom_abline()`)
4-
as it introduced undesirable issues far worse than the bug it fixed.
4+
as it introduced undesirable issues far worse than the bug it fixed
5+
(@thomasp85, #4514)
6+
* Fixes an issue in `ggsave()` when producing emf/wmf files (@yutannihilation,
7+
#4521)
8+
* Warn when grDevices specific arguments are passed to ragg devices (@thomasp85,
9+
#4524)
510

611
# ggplot2 3.3.4
712
This is a larger patch release fixing a huge number of bugs and introduces a

R/save.r

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ plot_dev <- function(device, filename = NULL, dpi = 300) {
178178
paper = "special")
179179
}
180180
if (requireNamespace('ragg', quietly = TRUE)) {
181-
png_dev <- ragg::agg_png
182-
jpeg_dev <- ragg::agg_jpeg
183-
tiff_dev <- ragg::agg_tiff
181+
png_dev <- absorb_grdevice_args(ragg::agg_png)
182+
jpeg_dev <- absorb_grdevice_args(ragg::agg_jpeg)
183+
tiff_dev <- absorb_grdevice_args(ragg::agg_tiff)
184184
} else {
185185
png_dev <- grDevices::png
186186
jpeg_dev <- grDevices::jpeg
@@ -220,3 +220,12 @@ plot_dev <- function(device, filename = NULL, dpi = 300) {
220220
grid.draw.ggplot <- function(x, recording = TRUE) {
221221
print(x)
222222
}
223+
224+
absorb_grdevice_args <- function(f) {
225+
function(..., type, antialias) {
226+
if (!missing(type) || !missing(antialias)) {
227+
warn("Using ragg device as default. Ignoring `type` and `antialias` arguments")
228+
}
229+
f(...)
230+
}
231+
}

0 commit comments

Comments
 (0)