david.luckett at industry.nsw.gov.au
2011-Feb-04 04:47 UTC
[R] Can an xyplot() plus legend be saved as an Enhanced Windows Metafile (EMF)?
I am trying to save some graphical output including a legend in the Windows Enhanced Metafile (EMF) format. This fails when xyplot() is used rather than plot(). Here is a simple example: require(lattice) a <- c(1:10) b <- c(2,4,5,2,3,5,7,8,9,5) # Output can be saved (or copied to the clipboard) as a Windows EMF image file # from the Graphics Device output window. plot(a , b) legend("topleft", "Test", title="Legend") # Output cannot be saved (or copied) as an EMF plot.new() xyplot(a ~ b) legend("topleft", "Test", title="Legend") I am using R version 2.12.0 (2010-10-15) on platform "i386-pc-mingw32" Thanks for any help or suggestions. David Luckett Senior Research Scientist EH Graham Centre Charles Sturt University and Industry & Investment NSW Wagga_Wagga NSW 2650 Australia www.GrahamCentre.net www.industry.nsw.gov.au This message is intended for the addressee named and may...{{dropped:7}}
Dennis Murphy
2011-Feb-04 08:59 UTC
[R] Can an xyplot() plus legend be saved as an Enhanced Windows Metafile (EMF)?
Hi: This is FAQ 7.22 (Why do lattice/trellis graphics not work?) You need to print() the plot, as in print(xyplot(a ~ b)) This problem also extends to ggplot2 graphics. (BTW, the legend statement after xyplot() won't work because the legend() function is meant for use in base graphics. Lattice has its own way of generating legends; see ?xyplot for further details and links.) HTH, Dennis On Thu, Feb 3, 2011 at 8:47 PM, <david.luckett@industry.nsw.gov.au> wrote:> I am trying to save some graphical output including a legend in the > Windows Enhanced Metafile (EMF) format. > This fails when xyplot() is used rather than plot(). > Here is a simple example: > > require(lattice) > a <- c(1:10) > b <- c(2,4,5,2,3,5,7,8,9,5) > > # Output can be saved (or copied to the clipboard) as a Windows EMF image > file > # from the Graphics Device output window. > plot(a , b) > legend("topleft", "Test", title="Legend") > > # Output cannot be saved (or copied) as an EMF > plot.new() > xyplot(a ~ b) > legend("topleft", "Test", title="Legend") > > I am using R version 2.12.0 (2010-10-15) on platform "i386-pc-mingw32" > > Thanks for any help or suggestions. > > David Luckett > Senior Research Scientist > > EH Graham Centre > Charles Sturt University and Industry & Investment NSW > Wagga_Wagga NSW 2650 Australia > www.GrahamCentre.net www.industry.nsw.gov.au > > > This message is intended for the addressee named and m...{{dropped:13}}