Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Capture plot output into variable
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Leo  
View profile  
 More options Nov 19 2012, 9:03 pm
From: Leo <leoasa...@gmail.com>
Date: Mon, 19 Nov 2012 18:03:39 -0800 (PST)
Local: Mon, Nov 19 2012 9:03 pm
Subject: Capture plot output into variable
Hi there,

Is it possible to re-direct the plot of the ggplot object to a
variable? Something that would work like capture.output()?

Thanks!
Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Roman Luštrik  
View profile  
 More options Nov 20 2012, 4:12 am
From: Roman Luštrik <roman.lust...@gmail.com>
Date: Tue, 20 Nov 2012 10:11:52 +0100
Local: Tues, Nov 20 2012 4:11 am
Subject: Re: Capture plot output into variable

You can assign the ggplot call to a variable, something that is done in the
help files of the function very often. Perhaps it would be clearer if you
told us what you're trying to do?

Shot in the dark, but maybe you're looking for `ggsave` which saves the
last plot called.

Cheers,
Roman

--
In God we trust, all others bring data.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 20 2012, 8:34 pm
From: Leo <leoasa...@gmail.com>
Date: Tue, 20 Nov 2012 17:34:18 -0800 (PST)
Local: Tues, Nov 20 2012 8:34 pm
Subject: Re: Capture plot output into variable

Hi Roman,

Sorry if I was not clear enough before. ggsave sinks the plot to a
connection (for example a file or url or the clipboard), and the example
objects in the help files are gg/ggplot objects.  These are not grid data
(pixels on a matrix), not until the plot is rendered into a connection.  I
want to capture the grid data, not the ggplot object. Does that make sense?

df<-data.frame(a=rnorm(20), b=rnorm(20))
p<-qplot(a,b,data=df)
class(p)

#this would not work, because the print function is directing the output to
the default stdout(),
#in this example a new window in the console, so the output (the plot data)
is not captured by capture.output()
z<-capture.output(print(p))
(z)

Leo


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Greg Snow  
View profile  
 More options Nov 21 2012, 6:42 pm
From: Greg Snow <538...@gmail.com>
Date: Wed, 21 Nov 2012 16:42:22 -0700
Local: Wed, Nov 21 2012 6:42 pm
Subject: Re: Capture plot output into variable

So you want to send the plot to a file?  look at the device functions like
jgep, png, pdf, bitmap, etc.  You can read the plot back into R as a matrix
or array using various tools like the png package or the EBImage package
from bioconductor.

--
Gregory (Greg) L. Snow Ph.D.
538...@gmail.com

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
ADP  
View profile  
 More options Nov 22 2012, 7:21 am
From: ADP <nicholasehamil...@gmail.com>
Date: Thu, 22 Nov 2012 04:21:55 -0800 (PST)
Local: Thurs, Nov 22 2012 7:21 am
Subject: Re: Capture plot output into variable

I was always under the impression you could do the following:

plot.object <- ggplot(...)
print(plot.object)

meaning that a ggplot object has been assigned to the 'plot.object'
variable.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Leo  
View profile  
 More options Nov 26 2012, 5:09 pm
From: Leo <leoasa...@gmail.com>
Date: Mon, 26 Nov 2012 14:08:58 -0800 (PST)
Local: Mon, Nov 26 2012 5:08 pm
Subject: Re: Capture plot output into variable
Thank you all for the replies. To Greg, yes, I can always do that, but
reading and writing to a disk takes time, especially when producing
many plots.  I have tried and timed it for my needs and it just takes
too long. To ADP, plot.object is a ggplot object, not a grid.

On Nov 22, 4:21 am, ADP <nicholasehamil...@gmail.com> wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »