Tuesday, December 18, 2012

R graphics - customizing text - text size

  • text size
    • there are ps and cex
    • ps defines an absolute text size
    • cex specifies a multiplicative modifier
    • final font size = fontsize * cex
    • cex is used e.g. in cex.axis (text drawn as tick labels), cex.lab (axis labels), cex.main (title), cex.sub (subtitle)
    • cex affects in most cases the plot symbols
    par(mfrow=c(2,3))
    par(mar=c(6,7,5,1)+0.1) ## set plot margins appropriate
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title")
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title (mult: 2)",cex.main=2,cex=2)
    plot(1:10,1:10,bty='n',xlab="x axis  (mult: 2)",ylab="y axis (mult: 2)",sub="subtitle",main="title",cex.lab=2,cex=3)
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle (mult: 2)",main="title (mult: 2)",cex.main=2,cex.sub=2,cex=0.5)
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle (mult: 2)",main="title (mult: 0.5)",cex.main=0.5,cex.sub=2,cex=seq(1,5))
    plot(1:10,1:10,bty='n',xlab="x axis  (mult: 3)",ylab="y axis (mult: 3)",sub="subtitle",main="title (mult: 4)", cex.lab=3,cex.main=4,cex=sample(4,10,replace=T))
    

    • ps is set through par()
    • the default value is 12
    • in the following graph ps is subsequently set to default, 9, 15, 5
    par(mfrow=c(2,2))
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title")
    par(ps=9)
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title")
    par(ps=15)
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title")
    par(ps=5)
    plot(1:10,1:10,bty='n',xlab="x axis",ylab="y axis",sub="subtitle",main="title")
    

Date: 2012-12-18 17:06:03 CET

Author: mandy

Org version 7.8.02 with Emacs version 23

Validate XHTML 1.0

No comments :

Post a Comment