RmyjuloR
RmyjuloR

Reputation: 438

ggplot2: trouble filling point when using stat_summary argument

I have the following code:

ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
stat_summary(fun.y=mean, geom='point', size=2, fill='white')

I know there are probably other ways of plotting this mean using the iris data. For my own data, though, it is the only way.

PROBLEM: the code above doesn't give white-filled points, but solid black points. Is there ar way to set the fill-colour when using the stat_summary argument?

Thanks!

Upvotes: 2

Views: 1812

Answers (1)

lukeA
lukeA

Reputation: 54287

Either use color instead of fill

ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
stat_summary(fun.y=mean, geom='point', size=2, color='white')

or use a symbol shape that has a fill and a border color

ggplot(iris, aes(x=Species, y=Sepal.Length)) + 
stat_summary(fun.y=mean, geom='point', size=2, shape=21, fill="blue", color="red")

Upvotes: 5

Related Questions