6
votes

I'm making a study map with ggplot2, and would like to use a black star symbol like this to plot city locations.

Is there a way to adjust the pch argument in geom_point to plot that symbol, maybe using a unicode expression? I've been successful at plotting other unicode symbols in ggplot2 with this code:

library(ggplot2)
p <- ggplot(mtcars, aes(wt, mpg))
p + geom_point(pch="\u2265", size=10)

When I use \u2605 instead for a black star symbol, the resulting plot just shows hollow rectangular symbols. Is there a different way to do this, or an alternative unicode for that symbol? I am using RStudio on my Mac if that makes a difference.

Thanks, Jay

1
I get the black star with your code (\2605), on Windows. I unknow this method, thanks!PereG
blog.revolutionanalytics.com/2015/11/… might be of generic helphrbrmstr
Works for me on Windows too - using \2605 as PereG suggestedMike Wise
I'm running Windows in Parallels and \u2605 works fine. Seems to be a Mac issue then.Jason

1 Answers

3
votes

You can use geom_text() instead of geom_point() and input directly a black star as the label (need to set family to a font that supports the character) ggplot(mtcars, aes(wt, mpg)) + geom_text(label="★", size=10, family = "HiraKakuPro-W3")