Use the half-filled squares on the ggplot2 facet_wrap shortcuts

I am trying to create a ggplot2 graph using half (and also square-filled) squares on labels, but ggplot2 on a Mac does not seem to support certain characters.

For example, when I type:

print("\u25E9") 

it shows a square that is half black, but when I try to use it in ggplot it doesn't print. I use facet_wrap, but it looks like the problem is in ggplot, which does not recognize Unicode characters.

I take this very useful example to illustrate:

 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 tried putting unicode in the expression and using plotmath, but my laptop doesn't seem to support this unique Unicode character, as warinig says in the plotmath help page:

"Any Unicode character can be entered in the UTF-8 locale, perhaps like the escape sequence \ uxxxx or \ Uxxxxxxxx, but the problem is whether the graphics device can display the character. The widest range of characters is likely to be available on X11 using cairo: see the man page for how additional fonts can help. This can often be used to display Greek letters in bold or in italics. Locales other than UTF-8 usually do not support characters that do not match languages , for which the current encoding was intended.

I think that the problem is mainly described in this post , but specifying cairo_pdf and quartz in pdf does not work, since I do not even see the output to the plot interactively.

so I was wondering if there is a way to create this shortcut from scratch, maybe? Can someone tell me how to do this or where to find a good example?

Thank you very much for any help!

I am using a Mac and this is 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 
+6
source share

All Articles