[R] Saving R Graph to a file

2012-11-04 Thread frespider
Hi

I am not sure why I can't get my plot saved to a file as .ps, I searched
online and I found that I have to use something is called postscript,png or
pdf function which I did but still not working.

Actually what I have is a matrix with almost 300-400 columns. I need to
create a histogram and boxplot for some columns as .ps file (with reasonable
size if i can adjust that would be nice also) so I can import them in my
latex code to display a good chart on my report.  And I found out R display
a certain limit of device. 
Can you please help me code this?

This an example I create 
data(CO2)
png(filename=C:/R/figure.png, height=295, width=300,  bg=white)
hist(CO2[,4])
device.off()
pdf(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
hist(CO2[,4])
postscript(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
hist(CO2[,4])


Thanks 





--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread R. Michael Weylandt
On Sun, Nov 4, 2012 at 4:16 AM, frespider frespi...@hotmail.com wrote:
 Hi

 I am not sure why I can't get my plot saved to a file as .ps, I searched
 online and I found that I have to use something is called postscript,png or
 pdf function which I did but still not working.

 Actually what I have is a matrix with almost 300-400 columns. I need to
 create a histogram and boxplot for some columns as .ps file (with reasonable
 size if i can adjust that would be nice also) so I can import them in my
 latex code to display a good chart on my report.  And I found out R display
 a certain limit of device.
 Can you please help me code this?

 This an example I create
 data(CO2)
 png(filename=C:/R/figure.png, height=295, width=300,  bg=white)
 hist(CO2[,4])
 device.off()

Did you try running your own code? It should have thrown an error here
since there's no device.off() function.

You just want dev.off()

Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread John
On Sat, 3 Nov 2012 21:16:49 -0700 (PDT)
frespider frespi...@hotmail.com wrote:

You're leaving out some critical information like the error messages, if
any, you receive.  That said, your example won't work properly because
it is not properly coded.

FI'm sure it gets tiresome being told to read the manual, but that is
the way you learn R.  For poscript output you need to read
?postscript() and follow the information there.  There are important
differences in detail between png(), pdf(), and postscript() that are
critical. CAREFULLY read the help for postscript(), and also check into
dev.off() use too. Your example doesn't restore things properly.  If
you do the above, you'll discover what is wrong with your example.


JWDougherty

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread Robert Baer

Some hints:
For pdf(), height and width are in inches, not pixels.  dev.off() is 
necessary after drawing the image for pdf(). The name for the file 
argument (file=c:/figure.xxx) is file not filename


hist(CO2[,5]) is more interesting

And yes,
?pdf
?postscript
?ping

On 11/3/2012 11:16 PM, frespider wrote:

Hi

I am not sure why I can't get my plot saved to a file as .ps, I searched
online and I found that I have to use something is called postscript,png or
pdf function which I did but still not working.

Actually what I have is a matrix with almost 300-400 columns. I need to
create a histogram and boxplot for some columns as .ps file (with reasonable
size if i can adjust that would be nice also) so I can import them in my
latex code to display a good chart on my report.  And I found out R display
a certain limit of device.
Can you please help me code this?

This an example I create
data(CO2)
png(filename=C:/R/figure.png, height=295, width=300,  bg=white)
hist(CO2[,4])
device.off()
pdf(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
hist(CO2[,4])
postscript(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
hist(CO2[,4])


Thanks





--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.



--
__
Robert W Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 US

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread Robert Baer

On 11/4/2012 4:32 AM, Robert Baer wrote:

Some hints:
For pdf(), height and width are in inches, not pixels.  dev.off() is 
necessary after drawing the image for pdf(). The name for the file 
argument (file=c:/figure.xxx) is file not filename


hist(CO2[,5]) is more interesting

And yes,
?pdf
?postscript

?png


On 11/3/2012 11:16 PM, frespider wrote:

Hi

I am not sure why I can't get my plot saved to a file as .ps, I searched
online and I found that I have to use something is called 
postscript,png or

pdf function which I did but still not working.

Actually what I have is a matrix with almost 300-400 columns. I need to
create a histogram and boxplot for some columns as .ps file (with 
reasonable

size if i can adjust that would be nice also) so I can import them in my
latex code to display a good chart on my report.  And I found out R 
display

a certain limit of device.
Can you please help me code this?

This an example I create
data(CO2)
png(filename=C:/R/figure.png, height=295, width=300, bg=white)
hist(CO2[,4])
device.off()
pdf(filename=C:/R/figure.pdf, height=295, width=300, bg=white)
hist(CO2[,4])
postscript(filename=C:/R/figure.pdf, height=295, width=300, 
bg=white)

hist(CO2[,4])


Thanks





--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369.html

Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide 
http://www.R-project.org/posting-guide.html

and provide commented, minimal, self-contained, reproducible code.






--
__
Robert W Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 US

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread Muhuri, Pradip (SAMHSA/CBHSQ)

Hello,

#Example 1: The following code to save svyboxplots works for me

pdf(boxplots_dthage.pdf, width = 1020) # 4 boxplots in 2 columns and 2 rows
par(mfrow=c(2,2),  oma=c(0,0,0,0))
# svyboxplot commands not shown
dev.off()


#Example 2: The following code to save a ggplot graph works for me:
# ggolot () not shown
print (p)
ggsave(file='Xfacet_abodill_age3.pdf', width=12, height=8) 


Thanks,

Pradip Muhuri

From: r-help-boun...@r-project.org [r-help-boun...@r-project.org] On Behalf Of 
Robert Baer [rb...@atsu.edu]
Sent: Sunday, November 04, 2012 5:32 AM
To: frespider
Cc: r-help@r-project.org
Subject: Re: [R] Saving R Graph to a file

Some hints:
For pdf(), height and width are in inches, not pixels.  dev.off() is
necessary after drawing the image for pdf(). The name for the file
argument (file=c:/figure.xxx) is file not filename

hist(CO2[,5]) is more interesting

And yes,
?pdf
?postscript
?ping

On 11/3/2012 11:16 PM, frespider wrote:
 Hi

 I am not sure why I can't get my plot saved to a file as .ps, I searched
 online and I found that I have to use something is called postscript,png or
 pdf function which I did but still not working.

 Actually what I have is a matrix with almost 300-400 columns. I need to
 create a histogram and boxplot for some columns as .ps file (with reasonable
 size if i can adjust that would be nice also) so I can import them in my
 latex code to display a good chart on my report.  And I found out R display
 a certain limit of device.
 Can you please help me code this?

 This an example I create
 data(CO2)
 png(filename=C:/R/figure.png, height=295, width=300,  bg=white)
 hist(CO2[,4])
 device.off()
 pdf(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
 hist(CO2[,4])
 postscript(filename=C:/R/figure.pdf, height=295, width=300,  bg=white)
 hist(CO2[,4])


 Thanks





 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369.html
 Sent from the R help mailing list archive at Nabble.com.

 __
 R-help@r-project.org mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


--
__
Robert W Baer, Ph.D.
Professor of Physiology
Kirksville College of Osteopathic Medicine
A. T. Still University of Health Sciences
Kirksville, MO 63501 US

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread frespider

Hi guys,
 
I really appreciated all your responds, I made mistake on my example below 
hwere I wrote device.off() where it should be dev.off().
 
I read all the help documnet for odf png and postscript before I posted my 
question but it didn't help.
 
Can some one please code an example?
 
Thanks
 



Date: Sun, 4 Nov 2012 02:39:13 -0800
From: ml-node+s789695n4648380...@n4.nabble.com
To: frespi...@hotmail.com
Subject: Re: Saving R Graph to a file

On 11/4/2012 4:32 AM, Robert Baer wrote: 

 Some hints: 
 For pdf(), height and width are in inches, not pixels.  dev.off() is 
 necessary after drawing the image for pdf(). The name for the file 
 argument (file=c:/figure.xxx) is file not filename 
 
 hist(CO2[,5]) is more interesting 
 
 And yes, 
 ?pdf 
 ?postscript ?png 

 
 On 11/3/2012 11:16 PM, frespider wrote: 
 Hi 
 
 I am not sure why I can't get my plot saved to a file as .ps, I searched 
 online and I found that I have to use something is called 
 postscript,png or 
 pdf function which I did but still not working. 
 
 Actually what I have is a matrix with almost 300-400 columns. I need to 
 create a histogram and boxplot for some columns as .ps file (with 
 reasonable 
 size if i can adjust that would be nice also) so I can import them in my 
 latex code to display a good chart on my report.  And I found out R 
 display 
 a certain limit of device. 
 Can you please help me code this? 
 
 This an example I create 
 data(CO2) 
 png(filename=C:/R/figure.png, height=295, width=300, bg=white) 
 hist(CO2[,4]) 
 device.off() 
 pdf(filename=C:/R/figure.pdf, height=295, width=300, bg=white) 
 hist(CO2[,4]) 
 postscript(filename=C:/R/figure.pdf, height=295, width=300, 
 bg=white) 
 hist(CO2[,4]) 
 
 
 Thanks 
 
 
 
 
 
 -- 
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369.html
 Sent from the R help mailing list archive at Nabble.com. 
 
 __ 
 [hidden email] mailing list 
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide 
 http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code. 
 
 

-- 
__ 
Robert W Baer, Ph.D. 
Professor of Physiology 
Kirksville College of Osteopathic Medicine 
A. T. Still University of Health Sciences 
Kirksville, MO 63501 US 

__ 
[hidden email] mailing list 
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code. 






If you reply to this email, your message will be added to the discussion 
below:http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369p4648380.html
 
To unsubscribe from Saving R Graph to a file, click here.
NAML  



--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-R-Graph-to-a-file-tp4648369p4648393.html
Sent from the R help mailing list archive at Nabble.com.
[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving R Graph to a file

2012-11-04 Thread R. Michael Weylandt
On Sun, Nov 4, 2012 at 1:18 PM, frespider frespi...@hotmail.com wrote:

 Hi guys,

 I really appreciated all your responds, I made mistake on my example below 
 hwere I wrote device.off() where it should be dev.off().

 I read all the help documnet for odf png and postscript before I posted my 
 question but it didn't help.

 Can some one please code an example?

 Thanks

Beyond the ones in the relevant help files,

png()
plot(1:5)
dev.off()

should make a plot.

Michael

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving a graph

2011-08-30 Thread Prof Brian Ripley

On Mon, 29 Aug 2011, Dieter Menne wrote:



Gang Chen-4 wrote:


However, my problem is that the file generated
from a graph of fixed size is too large (in the order of 10MB) because of
many data points in multiple scatterplots. Any suggestions?



Generate pdf, open and save it in Adobe Acrobat which does a compression
when the setting are correct.


*If* compression is enough, pdf() in R-devel does it, as does 
cairo_pdf() in current R.  And there are other ways than Acrobat to 
compress/compact a PDF file: see ?tools::compactPDF  and the 'Writing 
R Extensions' manual.


However, compression will not make that much of a difference (maybe a 
factor of 3), and the real problem seems to be the inappropriate plot. 
If you really need a plot with hundreds of thousands of points (or 
more), use a format like PNG -- but there are better ways to display 
such plots for most statistical purposes.  E.g. image and contour 
plots of densities, hexplots, density-dependent thinning 


--
Brian D. Ripley,  rip...@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving a graph

2011-08-30 Thread Jannis
Chang Cheng,


this question has been asked on this list for several times. I would suggest 
you search the list archive (http://r.789695.n4.nabble.com/R-help-f789696.html 
or www.rseek.com) prior to posting in the future. graph size many points pdf 
would give you at least 10 threads with detailed description. There are 
numerous solutions and most of them point into Dieters or Brian Ripleys 
directions.


Jannis

--- Dieter Menne dieter.me...@menne-biomed.de schrieb am Di, 30.8.2011:

 Von: Dieter Menne dieter.me...@menne-biomed.de
 Betreff: Re: [R] Saving a graph
 An: r-help@r-project.org
 Datum: Dienstag, 30. August, 2011 05:57 Uhr
 
 Gang Chen-4 wrote:
  
  However, my problem is that the file generated
  from a graph of fixed size is too large (in the order
 of 10MB) because of
  many data points in multiple scatterplots. Any
 suggestions?
  
 
 Generate pdf, open and save it in Adobe Acrobat which does
 a compression
 when the setting are correct.
 
 Dieter
   
 
 
 --
 View this message in context: 
 http://r.789695.n4.nabble.com/Saving-a-graph-tp3777456p3778015.html
 Sent from the R help mailing list archive at Nabble.com.
 
 __
 R-help@r-project.org
 mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained,
 reproducible code.


__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] Saving a graph

2011-08-29 Thread Gang Chen
I read somewhere that vector graphics such as eps or dpf are more favorable
than alternatives (jpeg, bmp or png) for publication because vector graphics
scale properly when enlarged. However, my problem is that the file generated
from a graph of fixed size is too large (in the order of 10MB) because of
many data points in multiple scatterplots. Any suggestions?

Thanks,
Gang

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] Saving a graph

2011-08-29 Thread Dieter Menne

Gang Chen-4 wrote:
 
 However, my problem is that the file generated
 from a graph of fixed size is too large (in the order of 10MB) because of
 many data points in multiple scatterplots. Any suggestions?
 

Generate pdf, open and save it in Adobe Acrobat which does a compression
when the setting are correct.

Dieter
  


--
View this message in context: 
http://r.789695.n4.nabble.com/Saving-a-graph-tp3777456p3778015.html
Sent from the R help mailing list archive at Nabble.com.

__
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.