[R] How to adjust fontsize of direct.label annotations in ggplot2?

Kristoffer Magnusson kristoffermagnusson at me.com
Mon Apr 2 09:06:09 CEST 2012


Hello!

I'm using direct.label() to annotate a ggplot, but I can't get it to change fontsize of annotations even tho I'm running the example from "?directlabels::dlcompare". Like this:

library(lattice)
library(ggplot2)
oldopt <- lattice.options(panel.error=NULL)

dts <- cbind(male=mdeaths,female=fdeaths,time=1:length(mdeaths))
require(reshape2)
ddf <- melt(as.data.frame(dts),id="time")
names(ddf) <- c("time","sex","deaths")
plots <- list(lattice=
             xyplot(deaths~time,ddf,groups=sex,type="l",xlim=c(-15,80)),
             ggplot2=
             qplot(time,deaths,data=ddf,colour=sex,geom="line")+xlim(-10,80))

if(names(dev.cur())!="postscript"){##to avoid error on pkg check
 ## Try some more exotic labeling options.
 exotic <- list("last.points",
                rot=c(0,180),
                fontsize=c(10,20),
                fontface=c("bold","italic"),
                fontfamily=c("mono","serif"),
                alpha=c(0.25,1))
 dlcompare(plots,list(exotic))
}

This will change fontface, fontfamily etc but not fontsize. Is it broke, or is there some other way to change fontsize?

I'm using RStudio 0.95.262.

Best regards,
Kristoffer Magnusson



More information about the R-help mailing list