Dear R users, I used R to draw many histograms and I would like to automatically save them into a jpeg file. I tried the following code since I know .ps file could be saved like this way: postscript("AYA_ELA.jpeg",horizontal=F,onefile=T) ......#some funtions inside here dev.off() There was a jpeg file, however, there is no pictures inside. Any suggestion? Thanks. Rebecca -------------------------------------------------- This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance. -------------------------------------------------- [[alternative HTML version deleted]]
jpeg(...) ##if you have X11 bitmap(..., type="jpeg") ##otherwise b On Jul 20, 2007, at 11:34 AM, Ding, Rebecca wrote:> Dear R users, > > I used R to draw many histograms and I would like to automatically > save > them into a jpeg file. I tried the following code since I know .ps > file > could be saved like this way: > > postscript("AYA_ELA.jpeg",horizontal=F,onefile=T) > ......#some funtions inside here > dev.off() > > There was a jpeg file, however, there is no pictures inside. Any > suggestion? > > Thanks. > > Rebecca
On 20-Jul-07 15:34:00, Ding, Rebecca wrote:> Dear R users, > > I used R to draw many histograms and I would like to automatically save > them into a jpeg file. I tried the following code since I know .ps file > could be saved like this way: > > postscript("AYA_ELA.jpeg",horizontal=F,onefile=T) > ......#some funtions inside here > dev.off() > > There was a jpeg file, however, there is no pictures inside. Any > suggestion? > > Thanks. > > RebeccaIf your "some functions inside here" do draw histograms, then there will indeed be pictures inside, but they will be in PostScript, since that is what is created when you use the postscript() device. The fact that you used ".jpeg" in the fileneam has nothing to do with it -- it will simply store the output, as PostScript, in the file whose name you give to it. It trusts you. You would have seen the PostScript pictures if you had used a PostScript viewer which reacts to the content of the files, whereas presumably your system expects a file whose name ends in ".jpeg" or ".jpg" to be a JPEG file; and therefore will use the wrong interpreter and fail to recognise the picture (as you have just proved). If you want to create JPEG files in a similar way, use the jpeg() function -- read ?jpeg for details. Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 20-Jul-07 Time: 17:07:20 ------------------------------ XFMail ------------------------------
Hi R users, Thanks for the jpeg() function. I do find it. However when I used par(mfrow=c(6,7)), which can put all my histograms in one page, R gave me the error message: Error in plot.new() : figure margins too large. The mfrow=c(6,7)statment was fine in postscript("AYA_ELA.ps"). Is there a way to solve that problem? Thanks. -----Original Message----- From: Benilton Carvalho [mailto:bcarvalh at jhsph.edu] Sent: Friday, July 20, 2007 11:45 AM To: Ding, Rebecca Cc: R-help at stat.math.ethz.ch Subject: Re: [R] automatically jpeg output jpeg(...) ##if you have X11 bitmap(..., type="jpeg") ##otherwise b On Jul 20, 2007, at 11:34 AM, Ding, Rebecca wrote:> Dear R users, > > I used R to draw many histograms and I would like to automatically > save them into a jpeg file. I tried the following code since I know > .ps file could be saved like this way: > > postscript("AYA_ELA.jpeg",horizontal=F,onefile=T) > ......#some funtions inside here > dev.off() > > There was a jpeg file, however, there were no pictures inside. Any > suggestion? > > Thanks. > > Rebecca-------------------------------------------------- This e-mail and any files transmitted with it may contain privileged or confidential information. It is solely for use by the individual for whom it is intended, even if addressed incorrectly. If you received this e-mail in error, please notify the sender; do not disclose, copy, distribute, or take any action in reliance on the contents of this information; and delete it from your system. Any other use of this e-mail is prohibited. Thank you for your compliance.
Dear R users, I used the following code to draw a scatter plot. plot(x,y,type="n") points(x,y,pch=1) And then I used the abline functions to draw two lines. I want to add the shadow between those two lines. abline(h=200) abline(h=300) Any suggestions? Thanks Rebecca -------------------------------------------------- This e-mail and any files transmitted with it may contain pr...{{dropped}}
see ?rect, or, for more general shapes, ?polygon ## EXAMPLES plot(c(0,500),c(0,500),type="n",las=1) rect(par("usr")[1],200,par("usr")[2],300,col="grey90") points(seq(0,500,length=3),seq(0,500,length=3)) plot(c(0,500),c(0,500),type="n",las=1) polygon((par("usr")[1:2])[c(1,1,2,2)], (c(200,300))[c(1,2,2,1)],col="grey90") points(seq(0,500,length=3),seq(0,500,length=3)) --- "Ding, Rebecca" <RDing at ETS.ORG> wrote:> Dear R users, > > I used the following code to draw a scatter plot. > > plot(x,y,type="n") > points(x,y,pch=1) > > And then I used the abline functions to draw two lines. I want to add > the shadow between those two lines. > > abline(h=200) > abline(h=300) > > Any suggestions? > > Thanks > > Rebecca > > -------------------------------------------------- > This e-mail and any files transmitted with it may contain pr...{{dropped}} > > ______________________________________________ > 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 > and provide commented, minimal, self-contained, reproducible code. >
Ding, Rebecca wrote:> Dear R users, > > I used the following code to draw a scatter plot. > > plot(x,y,type="n") > points(x,y,pch=1) > > And then I used the abline functions to draw two lines. I want to add > the shadow between those two lines. > > abline(h=200) > abline(h=300) > > Any suggestions? >Hi Rebecca, Have a look at polygon.shadow in the plotrix package. You can display a shadow-like figure based on any polygon. Jim