I am trying to change the key legend shape to circle (shape 21), but I can't seem to figure out how to do it.
library(ggpol)
#> Loading required package: ggplot2
df <- data.frame(Type = c("R"), value = c(100))
ggplot(df)
geom_parliament(aes(seats = value, fill = Type))
#> Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.
Created on 2022-12-27 with reprex v2.0.2
I have tried with guides, but it didn't work for me.
CodePudding user response:
I am not sure if this is desired behaviour (this might or might not have been a deliberate design decision by the author of this Geom), and might warrant an issue report to the package maintainer. ggpol::GeomParliament
uses rectGrob
to draw the legend key (you can see that by looking at GeomParliament$draw_key
). You can override this by first defining the correct draw_key
function (using the key_glyph
argument in the geom) and then override the aesthetics in guides
.
library(ggpol)
#> Loading required package: ggplot2
df <- data.frame(Type = c("R"), value = c(100))
ggplot(df)
geom_parliament(aes(seats = value, fill = Type), key_glyph = "point")
guides(fill = guide_legend(override.aes = list(size = 10, shape = 21)))
#> Warning: Using the `size` aesthetic in this geom was deprecated in ggplot2 3.4.0.
#> ℹ Please use `linewidth` in the `default_aes` field and elsewhere instead.
Created on 2022-12-27 with reprex v2.0.2