[R] Issues getting R to write image files

Kenny Larsen k.larsen at sheffield.ac.uk
Thu Jun 11 12:03:31 CEST 2009


Hi all,

Silly missing ") at the end of the plot command! is working now, just need
to remove the V1 and V2 that appear under my axis labels!

Cheers for all your help guys, much appreciated.

Kenny



Ted.Harding-2 wrote:
> 
> On 11-Jun-09 09:24:42, Tobias Verbeke wrote:
>> Hi Kenny,
>> 
>>> Have spent the last couple of days learning R and shell scripting to
>>> do
>>> batch plotting jobs. I have had success getting R to complete a filled
>>> contour plot and output to a file (.jpg or .tiff etc). However, when I
>>> try
>>> to do the same thing with the simple plot command the script seems to
>>> execute correctly yet there is no output. Below is my R code: 
>>> 
>>> file <- Sys.getenv("input_file") 
>>> tiff(paste( file, "tiff", sep="."))
>>> z <- read.table(file) 
>>> plot(z, type="l", xlim=range(0.6,2), col = "red", plot.title =
>>> title(main =
>>> file, xlab = "Wavelength (um)", ylab = "Intensity (arb.)) 
>> 
>> dev.off()
>> 
>>> q() 
>> 
>> You need to close the tiff graphics device you opened
>> using dev.off() before quitting.
>> 
>> HTH,
>> Tobias
> 
> I thought of that too -- since the graphics device needs to be
> closed before writing out to the file is completed and the file
> is closed.
> 
> However, it occurred to me that possibly q() would also have that
> effect, since it closes down R which should have the effect of
> closing devices, flushing buffers, and closing files (though I do
> not see this documented under "?q").
> 
> So I experimented.
> 
> 1. New R session.
> 2. Assign values to some variables.
> 3. Open a tiff() device, plot them, and quit R (no dev.off):
> 
>   tiff(file="temp.tif")
>   plot (X,P,  type="l")
>   lines(X,I.b,         col="blue" )
>   lines(X,I.m,         col="green")
>   lines(X,I.bm^2,      col="red")
>   q()
> 
> 4. End of R session, and temp.tif (which did not exist at the start)
> contains a good TIFF file with exactly what I expected to see. This
> confirmed my suspicions.
> 
> So it sould seem that dev.off() is not the answer.
> 
> Probably something is wrong along the line of reading in the data,
> or in specifying what to plot. But I can't see anything obvious in
> the code, so it may depend on what sort of structure z is, for instance.
> 
> Ted.
> 
> 
> --------------------------------------------------------------------
> E-Mail: (Ted Harding) <Ted.Harding at manchester.ac.uk>
> Fax-to-email: +44 (0)870 094 0861
> Date: 11-Jun-09                                       Time: 10:43:51
> ------------------------------ XFMail ------------------------------
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
View this message in context: http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23978518.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list