`draw_key_rect` fails to get color from outline when `fill` is `NA`
Ductmonkey opened this issue · 4 comments
Problem:
When using draw_key_rect with a geom that has fill = NA, it fails to catch the outline color and returns an invisible (NA) rectangle.
Minimal reprex:
library(ggplot2)
ggplot(mtcars, aes(disp, color = factor(cyl))) + geom_density(key_glyph = draw_key_rect)Created on 2023-08-10 with reprex v2.0.2
I think this is actually a bug. The rectangle draw key was meant to pick up the outline color when the fill color isn't given, but that apparently doesn't work. Not sure if it did work in the past and doesn't anymore or if it never worked.
The problem is in this line:
Line 66 in 2cd0e96
It is meant to pick colour when fill is not given, but here fill is set to NA and %||% tests for NULL.
There's nothing to change in the documentation, because the data, params, and size arguments to the draw key functions are not meant to be used by the end-user.
Thanks for clarifying, very helpful! Can you migrate this to a bug report then?
You can just edit the title accordingly. I've added the "bug" label.
Not realizing it was a bug, I had also asked this as a question on StackOverflow. Stefan's answer there may help on this:
https://stackoverflow.com/q/76872072/13210554
