Override.aes with geom_col seems to be not working

Hi,

I'm looking to alter the appearance of legend labels to display as filled circles (specifically, shape 19).

I came across a solution using override.aes on this page: link.

However, in my particular scenario where I'm utilizing geom_col, this method doesn't seem to work.

library(tidyverse)

euro <- as.data.frame(euro)

euro$name <- rownames(euro)

euro
#>            euro name
#> ATS   13.760300  ATS
#> BEF   40.339900  BEF
#> DEM    1.955830  DEM
#> ESP  166.386000  ESP
#> FIM    5.945730  FIM
#> FRF    6.559570  FRF
#> IEP    0.787564  IEP
#> ITL 1936.270000  ITL
#> LUF   40.339900  LUF
#> NLG    2.203710  NLG
#> PTE  200.482000  PTE

ggplot(data = euro, aes(x = name, y = euro, fill = name)) +
  geom_col() +
  guides(fill = guide_legend( 
    override.aes=list(shape = 19)))

Screenshot 2024-03-03 at 19.23.01

Have you ever faced this problem? Is there a resolution?

I'm aware of a workaround involving an empty dataset for labels, but a more direct approach would be preferable.

try:

ggplot(data = euro,
       aes(x = name,
           y = euro,
           fill = name)) +
  geom_col(key_glyph = draw_key_point) +
  guides(fill = guide_legend(override.aes = list(shape = 21)))

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.