I am trying to change the shape of the legends for a geom_col plot. By default, the legend is square, and I would like to change to round (or triangle or anything else). Since the colors are controlled by fill
, I would assume overwriting this parameter should do the trick:
library(ggplot2)
data("Titanic")
Titanic <- as.data.frame(Titanic)
ggplot(data = Titanic, aes(x = Class, y = Freq, fill = Survived)) + geom_col() +
guides(fill = guide_legend(override.aes = list(shape = 16)))
I also tried to be more specific
ggplot(data = Titanic, aes(x = Class, y = Freq, fill = Survived)) + geom_col() +
scale_shape_manual(values = c("No" = 16, "Yes" = 17))
But the legend doesn't change. Any advice?
(I did have a look to the related question Changing shape in legend ggplot2 but it doesn't seem to work either. I suppose because geom_point
is not used?)