Skip to content
Merged
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
5 changes: 3 additions & 2 deletions R/geom-raster.R
Original file line number Diff line number Diff line change
@@ -90,9 +90,10 @@ GeomRaster <- ggproto("GeomRaster", Geom,

draw_panel = function(self, data, panel_params, coord, interpolate = FALSE,
hjust = 0.5, vjust = 0.5) {
if (!inherits(coord, "CoordCartesian")) {
if (!coord$is_linear()) {
cli::cli_inform(c(
"{.fn {snake_class(self)}} only works with {.fn coord_cartesian}.",
"{.fn {snake_class(self)}} only works with linear coordinate systems, \\
not {.fn {snake_class(coord)}}.",
i = "Falling back to drawing as {.fn {snake_class(GeomRect)}}."
))
data$linewidth <- 0.3 # preventing anti-aliasing artefacts
8 changes: 8 additions & 0 deletions tests/testthat/_snaps/geom-raster.md
Original file line number Diff line number Diff line change
@@ -14,6 +14,14 @@

`vjust` must be a number, not the string "a".

---

Code
b <- ggplotGrob(p)
Message
`geom_raster()` only works with linear coordinate systems, not `coord_polar()`.
i Falling back to drawing as `geom_rect()`.

# geom_raster() fails with pattern fills

Problem while converting geom to grob.
2 changes: 1 addition & 1 deletion tests/testthat/test-geom-raster.R
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ test_that("geom_raster() checks input and coordinate system", {

df <- data_frame(x = rep(c(-1, 1), each = 3), y = rep(-1:1, 2), z = 1:6)
p <- ggplot(df, aes(x, y, fill = z)) + geom_raster() + coord_polar()
expect_message(ggplotGrob(p), "only works with")
expect_snapshot(b <- ggplotGrob(p))
})

test_that("geom_raster() fails with pattern fills", {