SHANE MILLER, BLOOMBERG/ 731 LEXIN
2009-Apr-08 14:05 UTC
[R] sourced plot commands not working
I have source a script running with no errors that ends in these lines: =============for (i in 2:3) win.graph() dev.set(2) levelplot(avg ~ procs * size, rrt, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) dev.set(3) levelplot(avg ~ procs * size, ort, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) ============The graphics devices windows appear, however, there is no graph and the background of each window is gray indicating no active graph. However, if I copy and paste these commands from the script and enter them into the console, they run fine. why? R 2.8.1 2008-12-22 on windows.
On Wed, 2009-04-08 at 10:05 -0400, SHANE MILLER, BLOOMBERG/ 731 LEXIN wrote:> I have source a script running with no errors that ends in these lines: > =============> for (i in 2:3) win.graph() > dev.set(2) > levelplot(avg ~ procs * size, rrt, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) > dev.set(3) > levelplot(avg ~ procs * size, ort, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) > ============> The graphics devices windows appear, however, there is no graph > and the background of each window is gray indicating no active > graph. > > However, if I copy and paste these commands from the script and > enter them into the console, they run fine. why?The plotting commands are lattice functions. These need to be printed to produce the plotting side effect you want. When entered at the command line printing is explicit. This doesn't happen when sourced. This is a FAQ 7.22:> > R 2.8.1 2008-12-22 on windows. > ______________________________________________ > 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.-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%
[Ooops, brain/fingers not well connected today, sent prematurely] On Wed, 2009-04-08 at 10:05 -0400, SHANE MILLER, BLOOMBERG/ 731 LEXIN wrote:> I have source a script running with no errors that ends in these lines: > =============> for (i in 2:3) win.graph() > dev.set(2) > levelplot(avg ~ procs * size, rrt, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) > dev.set(3) > levelplot(avg ~ procs * size, ort, drape=T, colorkey=T,main="ops/sec",scales=list(x=list(tick.number=15),y=list(log=10))) > ============> The graphics devices windows appear, however, there is no graph > and the background of each window is gray indicating no active > graph. > > However, if I copy and paste these commands from the script and > enter them into the console, they run fine. why?The plotting commands used here are lattice functions. These need to be printed to produce the plotting side effect you want. When entered at the command line printing is explicit. This doesn't happen when sourced. This is a FAQ 7.22: http://cran.r-project.org/doc/FAQ/R-FAQ.html#Why-do-lattice_002ftrellis-graphics-not-work_003f ?source does explain all of this. Solution; wrap your levelplot(...) in print(): print(levelplot(...)) HTH G> > R 2.8.1 2008-12-22 on windows. > ______________________________________________ > 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.-- %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~% Dr. Gavin Simpson [t] +44 (0)20 7679 0522 ECRC, UCL Geography, [f] +44 (0)20 7679 0565 Pearson Building, [e] gavin.simpsonATNOSPAMucl.ac.uk Gower Street, London [w] http://www.ucl.ac.uk/~ucfagls/ UK. WC1E 6BT. [w] http://www.freshwaters.org.uk %~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%~%