-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix limits on
scale_colour_gradient2()
(#2300)
* Fix limits on `scale_colour_gradient2()` so limits are imposed before rescaling. * Add test for limit fix for `scale_*_gradient2()`.
- Loading branch information
1 parent
d00d890
commit 582acfe
Showing
3 changed files
with
17 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
context("scale_gradient") | ||
|
||
# Limits ------------------------------------------------------------------ | ||
|
||
test_that("points outside the limits are plotted as NA", { | ||
df <- data.frame(x = c(0, 1, 2)) | ||
p <- ggplot(df, aes(x, 1, fill = x)) + | ||
geom_col() + | ||
scale_fill_gradient2(limits = c(-1, 1), midpoint = 2, na.value = "orange") | ||
|
||
correct_fill <- c("#B26D65", "#DCB4AF", "orange") | ||
expect_equivalent(layer_data(p)$fill, correct_fill) | ||
}) |