-
Couldn't load subscription status.
- Fork 30
Closed
Description
This is an upstream issue to be fixed in ggplot2, but I'm also reporting it here for visibility if others encounter similar problems.
In ggplot2 v4.0.0, there is a bug in draw_key_rect() where fill isn't used.
library(ggdist)
library(ggplot2)
data.frame(
t = 1:10,
y = distributional::dist_normal(1:10, 1)
) |>
ggplot(aes(x = t, ydist = y)) +
stat_lineribbon(aes(fill = after_stat(level)), .width = c(.5, .8, .95)) +
scale_fill_brewer()Created on 2025-09-12 with reprex v2.1.1
draw_key_rect isn't actually used in ggplot2's geoms anywhere, they instead use draw_key_polygon which should be better tested.
A quick fix (for users and for ggdist) is to replace usage of draw_key_rect with draw_key_polygon:
library(ggdist)
library(ggplot2)
data.frame(
t = 1:10,
y = distributional::dist_normal(1:10, 1)
) |>
ggplot(aes(x = t, ydist = y)) +
stat_lineribbon(aes(fill = after_stat(level)), .width = c(.5, .8, .95), key_glyph = draw_key_polygon) +
scale_fill_brewer()Created on 2025-09-12 with reprex v2.1.1
A PR fixing this upstream in ggplot2 has been submitted here: tidyverse/ggplot2#6609
Metadata
Metadata
Assignees
Labels
No labels

