[R] ggplot2: How to change font of labels in geom_text

Ronan Reilly ronan.reilly at gmail.com
Thu Dec 31 21:14:47 CET 2009


Happy New Year everyone.

I have what I hope is a simple-to-answer question.  In the code sample
below, I'm using a tile plot to plot a continuous measure and overlaying the
plot with labels.  I need to print the labels in courier, but there appears
to be no way to override the default font setting in geom_text.  I've
scoured the web for clues on how to do this, but found nothing relevant.

Any help would be very much appreciated.

Ronan  

---- start code snippet ----

small.df <- data.frame(scan(what=list(row=0, col=0, item="", latency=0)))
1 1 ab 0.1
1 2 bc 0.2
1 3 cd 0.3
2 1 de 0.4
2 2 ef 0.5
2 3 fg 0.6
3 1 gh 0.7
3 2 hi 0.8
3 3 ij 0.9

small.df

p <- ggplot(small.df, aes(x=row, y=col, label=item, fill=latency))
p <- p + geom_tile()
p <- p + geom_text(colour="white")
print(p)

---- end code snippet ----

--
Professor Ronan Reilly
Department of Computer Science
NUI Maynooth
Maynooth
Co. Kildare
IRELAND

t: +353-1-7083846
e: Ronan.Reilly at nuim.ie
w: http://www.cs.nuim.ie; http://cortex.cs.nuim.ie




More information about the R-help mailing list