You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
geom_raster drops legend when col and fill aesthetics added #5324
legend works with geom_tile when col then fill aesthetics added
library(tidyverse)
#legend works with geom_tileggplot2::faithfuld|>
head(10) |>
ggplot() +
geom_tile(aes(x=waiting, y=eruptions, col=density, fill=density))
legend does not work with geom_raster when col then fill aesthetics added
#legend does not work with geom_rasterggplot2::faithfuld|>
head(10) |>
ggplot() +
geom_raster(aes(x=waiting, y=eruptions, col=density, fill=density))
#> Warning in geom_raster(aes(x = waiting, y = eruptions, col = density, fill =#> density)): Ignoring unknown aesthetics: colour
Works if the order of aesthetics is fill then col, but not the other way around
library(tidyverse)
#legend works if aesthetic order is fill then colggplot2::faithfuld|>
head(10) |>
ggplot() +
geom_raster(aes(x=waiting, y=eruptions, fill=density, col=density))
#> Warning in geom_raster(aes(x = waiting, y = eruptions, fill = density, col =#> density)): Ignoring unknown aesthetics: colour
Good catch! From some brief experimentation, it seems to be dropped due to the legend key data having colour as the aesthetics name after merging fill and colour guides, which then is discarded by the guide_geom()/GuideColourbar$get_layer_key(). I think this should be fixed in the guide_merge()/GuideColourbar$merge() step.
Activity
davidhodge931 commentedon Jun 14, 2023
Works if the order of aesthetics is fill then col, but not the other way around
Created on 2023-06-15 with reprex v2.0.2
teunbrand commentedon Jun 17, 2023
Good catch! From some brief experimentation, it seems to be dropped due to the legend key data having
colouras the aesthetics name after merging fill and colour guides, which then is discarded by theguide_geom()/GuideColourbar$get_layer_key(). I think this should be fixed in theguide_merge()/GuideColourbar$merge()step.