问题
I am working on the most recent of R on Ubuntu. After I created some plots, the cursor became a '+' and won't let me access the copy and paste options. Moreover unlike the R in Windows, it does not have a toolbar that have the 'Copy' option. What can I do to copy my plots?
Thank you.
回答1:
The default graphics device when using R under Linux is something called "X11": basically, it creates the window in which you see your plot.
It's a very basic window without many features so the answer is: you can't copy/paste from it. Instead, you need to create a different graphics device and write the plot to it. Most people would choose something like a PNG file, like this:
png(file = "myplot.png") # create PNG device
plot(x) # do the plot
dev.off() # return to default device (X11)
And you now have a PNG file named "myplot.png" in the current directory.
回答2:
Neil provides part of the answer. Basically, the stock Ubuntu build gives you
pdf()for what may be the best format for publication graphicspng()for what may be useful on the webjpeg()
as well as the abilty to write the current plot via dev.copy().
But then there is CRAN and a whole slew of add-on packages, including some as binaries for Ubuntu:
- cairoDevice via
r-cran-cairoDevicein Ubuntu
plus at least one other Cairo package or rforge.net, and at least abother SVG package can all write scalable vector graphics (SVG).
In the end it all depends on what you want to do with the graph file. Which you didn't say so it is hard to be specific.
回答3:
If you want GUI like options like RGUI I would suggest you use RStudio on Ubuntu (as well as on any other OS; http://rstudio.org/).
来源:https://stackoverflow.com/questions/6838851/how-to-copy-plots-in-r-when-working-in-ubuntu