[R] X11 graphics windows under CMD BATCH

David Scott d.scott at auckland.ac.nz
Wed Oct 24 21:19:25 CEST 2007


Not sure about answering your original question, but why not write the 
graphics output to a file, then fire up a viewer?

David Scott

On Wed, 24 Oct 2007, Luke Spadavecchia wrote:

> Hi there,
>
> I am trying to plot some output from a  FORTRAN (ifort) program using
> R (2.5.1) under batch mode. In the FORTRAN code, I call R in batch
> mode to execute a script called fig1.R using something like
>
> PROGRAM test
> USE IFPORT
> 	IMPLICIT NONE
>
> 	DO
> 		!Some function which makes an output file called ~/fortran_output.txt
> 		CALL myfunc()
>
> 		!System call to R plotting routine
> 		CALL SYSTEM ("open -a x11")
> 		CALL SYSTEM ("R CMD BATCH ~/fig1.R")
> 	END DO
>
> END PROGRAM test
>
> The system call goes through fine, and R fires up and processes the
> contents of fig1.R which are something like:
>
> Sys.setenv("DISPLAY"=":0.0")
> Data<-read.table("~/fortran_output.txt")
> x11(width=12)
> plot(Data$var1,Data$var2)
>
> My problem is that I want the x11 window which the plot appears in to
> persist after R exits; currently the figure flashes up momentarily,
> then disappears as R exits. One option is to try and stall the exit
> of R, by sticking a big loop at the end of the code, but this means
> my FORTRAN program is hanging about waiting for the loop to finish,
> and my plot still disappears. Is there any equivalent to -persist in
> GNUPLOT to allow the x11 window to stay open after R exits, so I can
> examine the results while the program continues?
>
> To put all this in context, I want to examine the results of a
> simulated annealing process at each temperature reduction stage of
> the annealing schedule. I am not doing the annealing in R for reasons
> of speed: I only want to use R as a graphics engine.
>
> Many thanks
>
> Luke Spadavecchia
>
> ______________________________________________
> 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.
>

_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
 		The University of Auckland, PB 92019
 		Auckland 1142,    NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz

Graduate Officer, Department of Statistics
Director of Consulting, Department of Statistics



More information about the R-help mailing list