Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion R/geom-raster.R
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,5 @@ GeomRaster <- ggproto("GeomRaster", Geom,
default.units = "native", interpolate = interpolate
)
},
draw_key = draw_key_rect
draw_key = draw_key_polygon
)
8 changes: 3 additions & 5 deletions R/legend-draw.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,18 @@ draw_key_abline <- function(data, params, size) {
#' @export
#' @rdname draw_key
draw_key_rect <- function(data, params, size) {
colour <- if (is.na(data$fill %||% NA)) data$colour
rectGrob(gp = gg_par(
col = NA,
fill = fill_alpha(data$fill %||% data$colour %||% "grey20", data$alpha),
fill = fill_alpha(colour %||% "grey20", data$alpha),
lty = data$linetype %||% 1
))
}
#' @export
#' @rdname draw_key
draw_key_polygon <- function(data, params, size) {
if (is.null(data$linewidth)) {
data$linewidth <- 0.5
}

lwd <- data$linewidth
lwd <- data$linewidth %||% 0

grob <- rectGrob(
width = unit(1, "npc") - unit(lwd, "mm"),
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/geom-raster/discrete-positions.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions tests/testthat/_snaps/geom-raster/irregular-categorical.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions tests/testthat/_snaps/geom-raster/rectangle-fallback.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading