Skip to content

Copying from graphics window in OS X

9 messages · Sean Davis, Chris Wiita, Felipe +3 more

#
I'm running R from an Xterm window is OSX-Tiger.  Graphical windows 
appear as they should, but I'm having trouble copying from them--using 
cmd+c or the Copy option in the Edit menu won't place the graph in the 
clipboard (when I paste into a running OS X app, I get whatever was the 
last copied thing from a non-x11 window).  Any ideas on how to copy from 
a xterm-launched graphical window?  I can copy/paste into and out of the 
xterm command line, but I can't get anything from a graphical window.

Thanks!
#
On 9/15/05 3:14 PM, "Chris Wiita" <cgwiita at ucla.edu> wrote:

            
I don't think it is possible, but I would love to be corrected.  You can
simple make a png, pdf, etc. if you want to save the graphic.

Sean
#
I hope there is a way...at the moment an os X screen grab is the only 
way to get a quick copy. When I ran Cygwin on a PC, copying from graphic 
windows was as easy as ctrl+c--so it doesn't sound like an X11 
limitation.  I'd like to know what Cygwin was doing in the background...
Sean Davis wrote:

            
#
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I'm using R for Mac OS X Aqua GUI. It allows me to copy graphs directly,
simply with command-c.
It's pretty nice, you can give it a try.
Greetings.
Felipe
Chris Wiita wrote:
| I'm running R from an Xterm window is OSX-Tiger.  Graphical windows
| appear as they should, but I'm having trouble copying from them--using
| cmd+c or the Copy option in the Edit menu won't place the graph in the
| clipboard (when I paste into a running OS X app, I get whatever was the
| last copied thing from a non-x11 window).  Any ideas on how to copy from
| a xterm-launched graphical window?  I can copy/paste into and out of the
| xterm command line, but I can't get anything from a graphical window.
|
| Thanks!
|
| ______________________________________________
| R-help at stat.math.ethz.ch mailing list
| https://stat.ethz.ch/mailman/listinfo/r-help
| PLEASE do read the posting guide!
http://www.R-project.org/posting-guide.html
|
|
-----BEGIN PGP SIGNATURE-----

iEYEARECAAYFAkMp1eYACgkQWtdQtNzjBl59JgCfV7JR8kbsbYvMQG6OVt/plNTd
1S8AnRTHe6cRrwr0mxbJJGXmdkRibDvV
=Pc3t
-----END PGP SIGNATURE-----
#
You can try FreeSnap, a screen capture program for OS X:
    http://www.efritz.net/software.html

Also, why are you running R from an XTerm?  There is an OS X native
version of R that might be better integrated with OS X for doing
screen captures:
   http://cran.stat.ucla.edu/bin/macosx/

Jamie
On 9/15/05, Chris Wiita <cgwiita at ucla.edu> wrote:
#
I just tried using Ctrl-C to do a copy a plot from a graphic window
using the Cocoa version of OS X that you can download from the link
below and I was able to paste the plot into a document.

Jamie
On 9/15/05, Jamieson Cobleigh <cobleigh at gmail.com> wrote:

            
#
I'm connecting over SSH to a linux server to do calculations, so I need 
to be able to run the remote linux console on the Mac.
Jamieson Cobleigh wrote:

            
#
It does look like a Cygwin feature. Possibly, another window manager, 
not Apple's XQuartz, would have something.

You could try xwd, which is available in the usual place, /usr/X11R6/bin.

I have written a couple of helper functions that might make things a 
little less painful if you don't find a satisfactory 
capture-to-clipboard solution.

Use them something like this:
    x11()            ## open a graphics window
    plot(....)        ## make a plot
    pl.copy()       ## copy it to a pdf (pdf is the default)
    pl.email()      ## email it to someone (default recipient is me)

    pl.copy() copies the current graph to a pdf, png, jpeg, eps, or ps file.
    pl.email(), called immediately after pl.copy(), will email that file.

pl.email() assumes that outgoing email can be sent using the 'mail' 
or 'mailx' command, so
you might to modify pl.email() for your linux server. It also assumes 
uuencode is available.

-Don
function (file = "currentgraph", gtype = c("pdf", "png", "jpeg", "eps",
     "ps"), width = 9, height = 5, wpixels = 700, hpixels = 400,
     time = FALSE, horizontal = FALSE, enc.for.ps = "ISOLatin1",
     enc.for.pdf = "AdobeStd", ...)
{
     gtype <- match.arg(gtype)
     file <- paste(file, if (time)
         format(Sys.time(), "-%Y-%m-%d-%H-%M")
     else "", ".", gtype, sep = "")
     gr <- recordPlot()
     switch(gtype, pdf = {
         pdf(file, width = width, height = height, onefile = FALSE,
             encoding = enc.for.pdf, ...)
     }, png = {
         png(file, width = wpixels, height = hpixels, ...)
     }, jpeg = {
         jpeg(file, width = wpixels, height = hpixels, ...)
     }, eps = {
         postscript(file, width = width, height = height, horizontal = 
horizontal,
             onefile = FALSE, paper = "special", encoding = enc.for.ps,
             ...)
     }, ps = {
         postscript(file, width = width, height = height, horizontal = 
horizontal,
             onefile = FALSE, paper = "special", encoding = enc.for.ps,
             ...)
     }, stop("invalid gtype\n"))
     replayPlot(gr)
     dev.off()
     assign("current.file", file, pos = ".GlobalEnv")
     cat("file is ", file, "\nfile name is stored in object \"current.file\"\n",
         sep = "")
     invisible(gr)
}
function (to = "macq at llnl.gov", file = current.file, from = Sys.getenv("USER"),
     subject = paste("Graph from", from), note = "", mail.cmd = {
         if (Sys.info()["sysname"] == "SunOS")
             "mailx"
         else "mail"
     })
{
     cmd <- paste("uuencode ", file, " ", file, " | ", mail.cmd,
         " -s \"", subject, "\" ", to, sep = "")
     cat("mailing with command:\n", cmd, "\n")
     system(cmd)
}
At 12:49 PM -0700 9/15/05, Chris Wiita wrote: