Skip to content

Commit 6694817

Browse files
committed
add test for geom_tile
1 parent 7d0890d commit 6694817

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ Rapp.history
44
*.RData
55
*.Rproj.user
66
.Rproj.user
7+
build_site.R

tests/testthat/test-ggplot-heatmap.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,18 @@ test_that("geom_tile is translated to type=heatmap", {
2828
all(grepl("^value: [-]?[0-9]+$", c(L$data[[1]]$text)))
2929
)
3030
})
31+
32+
d <- expand.grid(
33+
x = seq(0, 1, .005),
34+
y = seq(0, 1, .005)
35+
)
36+
d$z <- with(d, (1 - y) * x / ((1 - y) * x + y * (1 - x)))
37+
p <- ggplot(data = d, aes(x, y)) +
38+
geom_tile(aes(fill = z)) +
39+
scale_fill_gradient2(low = '#67001f', mid = 'white', high = '#053061', midpoint = .5)
40+
41+
test_that("geom_tile() scale_fill_gradient2()", {
42+
L <- save_outputs(p, "heatmap-midpoint")
43+
# one trace is for the colorbar
44+
expect_equal(length(L$data), 2)
45+
})

0 commit comments

Comments
 (0)