[R] Adding text to both grid and base graphs

Rik Schoemaker rik.schoemaker at exprimo.com
Mon Mar 9 16:14:27 CET 2009


Dear all,

I'm stuck with the following problem: 

I generate graphs using both the grid system (with lattice) and the base
system. I'd like to be able to identify these graphs later on with a bit of
identifying text (e.g. a date and some comments). Adding text to these
graphs cannot be done using a common system if you want to save them as emf
files. I now use:

mtext("labelling
text",outer=TRUE,at=0.5,adj=0.5,line=-1.1,side=1,cex=0.7,col="darkgrey")

for base graphs and 

grid.text("labelling text",x=0.5,y=0.005,just="bottom",gp=gpar(fontsize=8,
col="darkgrey"))

for grid graphs.

Unfortunately if I were to use mtext on a grid graph and copy to emf, I get
the error:
Error in dev.copy(win.metafile, pltfile) : invalid graphics state

Is there a way to detect the current graphics state so I can choose which
command to give automatically? (or is there an easier way to go about this?)

Thanks very much in advance,

Rik


----------------------------
This e-mail message has been scanned for Viruses by Norman Virus Control and it's Content by MailMarshal




More information about the R-help mailing list