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
Richard.Cotton at hsl.gov.uk
2009-Mar-09 15:44 UTC
[R] Adding text to both grid and base graphs
> 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 bitof> 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 asemf> 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("labellingtext",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, Iget> 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 choosewhich> command to give automatically? (or is there an easier way to go aboutthis?) The easier way: use win.metafile to save your plots, e.g. win.metafile("base.emf") plot(runif(50)) mtext("labelling text",outer=TRUE,at=0.5,adj=0.5,line=-1.1,side=1,cex=0.7,col="darkgrey") dev.off() win.metafile("grid.emf") xyplot(runif(50)~1:50) grid.text("labelling text",x=0.5,y=0.005,just="bottom",gp=gpar(fontsize=8, col="darkgrey")) dev.off() Regards, Richie. Mathematical Sciences Unit HSL ------------------------------------------------------------------------ ATTENTION: This message contains privileged and confidential inform...{{dropped:20}}