[R] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

Hi All, 

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.)) 
q() 

The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and can
clearly write tiff's as it managed it with the filled contours. 

Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 

Cheers, 

Kenny

-- 
View this message in context: 
http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23977785.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] Issues getting R to write image files

2009-06-11 Thread Mario Valle

Has tried to close the image file at the end?
Do:
dev.off()

Hope it helps
   mario
Kenny Larsen wrote:
Hi All, 


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.)) 
q() 


The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and can
clearly write tiff's as it managed it with the filled contours. 


Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 

Cheers, 


Kenny

  



--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82

__
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] Issues getting R to write image files

2009-06-11 Thread Tobias Verbeke

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

__
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] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

Thanks all, I added the dev.off() and although it didn't solve it it no doubt
tidies things up on closing. I have got it working now, it is something in
the plot() line, as removing all teh options solves it. I will work
through adding them in one by one!

Kenny


Mario Valle wrote:
 
 Has tried to close the image file at the end?
 Do:
 dev.off()
 
 Hope it helps
 mario
 Kenny Larsen wrote:
 Hi All, 

 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.)) 
 q() 

 The data file is simply 2 columns of real numbers. The system it is
 running
 on is a linux box from the command line, but does have the Xlibrarys and
 can
 clearly write tiff's as it managed it with the filled contours. 

 Bear in mind I only started with both linux and R a couple of days ago,
 so
 be gentle if it is something silly! 

 Cheers, 

 Kenny

   
 
 
 -- 
 Ing. Mario Valle
 Data Analysis and Visualization Group|
 http://www.cscs.ch/~mvalle
 Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91)
 610.82.60
 v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91)
 610.82.82
 
 __
 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.
 
 

-- 
View this message in context: 
http://www.nabble.com/Issues-getting-R-to-write-image-files-tp23977785p23978106.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] Issues getting R to write image files

2009-06-11 Thread Ted Harding
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.hard...@manchester.ac.uk
Fax-to-email: +44 (0)870 094 0861
Date: 11-Jun-09   Time: 10:43:51
-- XFMail --

__
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] Issues getting R to write image files

2009-06-11 Thread Kenny Larsen

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.hard...@manchester.ac.uk
 Fax-to-email: +44 (0)870 094 0861
 Date: 11-Jun-09   Time: 10:43:51
 -- XFMail --
 
 __
 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.
 
 

-- 
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.

__
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] Issues getting R to write image files

2009-06-11 Thread Prof Brian Ripley
q() does call the internal version of graphics.off() which closes all 
open graphics devices.


On Thu, 11 Jun 2009, Mario Valle wrote:


Has tried to close the image file at the end?
Do:
dev.off()

Hope it helps
  mario
Kenny Larsen wrote:
Hi All, 
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.)) q() 
The data file is simply 2 columns of real numbers. The system it is running
on is a linux box from the command line, but does have the Xlibrarys and 
can
clearly write tiff's as it managed it with the filled contours. 
Bear in mind I only started with both linux and R a couple of days ago, so
be gentle if it is something silly! 
Cheers, 
Kenny






--
Ing. Mario Valle
Data Analysis and Visualization Group| http://www.cscs.ch/~mvalle
Swiss National Supercomputing Centre (CSCS)  | Tel:  +41 (91) 610.82.60
v. Cantonale Galleria 2, 6928 Manno, Switzerland | Fax:  +41 (91) 610.82.82


--
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.