Tuesday, December 18, 2012

R graphics - customizing text - font

  • fonts
    • you can set the family via the family argument within every plot command
    • the specified font must be installed
    • the generic (R-) fonts are always available (serif, sans, mono)
    • only the text produced by this command will be affected
    par(mfrow=c(2,3))
    par(mar=c(6,7,5,1)+0.1) ## set plot margins appropriate
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Waree",family="Waree",cex=2)
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Nimbus Mono",family="Nimbus Mono",cex=2)
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Century Schoolbook L",family="Century Schoolbook L",cex=2)
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Liberation Serif",family="Liberation Serif",cex=2)
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="URW Gothic L",family="URW Gothic L",cex=2)
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="URW Palladio L",family="URW Palladio L",cex=2)
    



    • it is better to set family via par, so all following produced text is uniform
    par(mfrow=c(2,2))
    par(mar=c(6,7,5,1)+0.1) ## set plot margins appropriate
    par(family="Waree") ## set family
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Waree",cex=2)
    par(family="URW Palladio L") ## set family
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="URW Palladio L",cex=2)
    par(family="Tlwg Typo") ## set family
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Tlwg Typo",cex=2)
    par(family="Ubuntu Mono") ## set family
    plot(c(0,1),c(0,1),bty='n',type='n',xlab="x axis",ylab="y axis",cex.lab=2)
    text(.5,.5,labels="Ubuntu Mono",cex=2)
    

Date: 2012-12-18 17:46:00 CET

Author: mandy

Org version 7.8.02 with Emacs version 23

Validate XHTML 1.0

No comments :

Post a Comment