Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions R/tinytheme.R
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ tinytheme = function(
settings[[n]] = dots[[n]]
}

# `col.default` < 0 gotcha for user-supplied palettes.(#627)
if ("palette.qualitative" %in% names(dots) &&
!("col.default" %in% names(dots)) &&
is.numeric(settings[["col.default"]]) &&
settings[["col.default"]] < 0L) {
settings[["col.default"]] = abs(settings[["col.default"]])
}

# Compute mgp from spacing primitives when dynmar is active and the user
# didn't provide an explicit mgp override. The near edge of margin text
# (facing the plot region) aligns with the half-cell boundary (0.5*cex from
Expand Down
11 changes: 11 additions & 0 deletions inst/tinytest/test-tinytheme.R
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,14 @@ f = function () {
theme = list("clean", palette.qualitative = pal, pch = 21))
}
expect_snapshot_plot(f, label = "tinytheme_ephemeral_palette_function_qualitative")


# User palette override should not be trimmed by a theme's negative
# col.default (e.g. bw's -1), which would silently recycle colours. (#627)
f = function() {
plt(
Sepal.Length ~ Petal.Length | Species, iris,
theme = list("bw", palette.qualitative = c("red", "blue", "green"))
)
}
expect_silent(f())
Loading