I am trying to produce a ggplot2 graph using half (and also one quarter filled) squares on the labels, but ggplot2 on a Mac doesn't seem to support certain symbols.
For example, when I type:
print("\u25E9")
it shows a square which is half black, but when I try to use it in ggplot it doesn't print. I am using facet_wrap, but it looks like the problem is in ggplot that doesn't recognise the Unicode symbols.
I am taking this very helpful example for illustration:
junk<-data.frame(gug=c(
rep( paste("\u25E9"), 10),
rep( paste("\u25E8"), 10)
)
)
junk$eks<-1:nrow(junk)
junk$why<-with(junk, as.numeric(gug) + eks)
print(summary(junk))
library(ggplot2)
print(
ggplot(data=junk, mapping=aes(x=eks, y=why)) +
geom_point() +
facet_wrap(~ gug)
)
I have tried putting the unicode in an expression and using plotmath but my laptop doens't seem to support this particular unicode symbol, as the warinig says on the plotmath help page:
"In a UTF-8 locale any Unicode character can be entered, perhaps as a \uxxxx or \Uxxxxxxxx escape sequence, but the issue is whether the graphics device is able to display the character. The widest range of characters is likely to be available in the X11 device using cairo: see its help page for how installing additional fonts can help. This can often be used to display Greek letters in bold or italic. In non-UTF-8 locales there is normally no support for symbols not in the languages for which the current encoding was intended."
I think the problem is basically described in this post, but specifying cairo_pdf and quartz in the pdf doesn't work, since I cannot even see an output in the plot interctively.
so I was wondering if there is a way to create this label from scratch maybe? Can anybody plase give me a clue how to do this or where to find a good example?
Thank you VERY much for ANY help!
I'm using a Mac and this is the SessionInfo:
> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_GB.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] Unicode_0.1-3 ggplot2_0.9.3.1 plyr_1.8 reshape2_1.2.2
loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4 grid_3.0.2
[5] gtable_0.1.2 labeling_0.2 MASS_7.3-29 munsell_0.4.2
[9] proto_0.3-10 RColorBrewer_1.0-5 scales_0.2.3 stringr_0.6.2
[13] tcltk_3.0.2 tools_3.0.2