[R] mixing grid and traditional graphics

Spencer Graves spencer.graves at structuremonitoring.com
Mon Jun 30 01:56:41 CEST 2014


       I'm confused with the results I'm getting from mixing grid and 
traditional graphics.  A toy example appears below:  The png file 
created by gridFn() shows "a label" over Africa, as expected. However, 
when run interactively, "a label" appears for roughly half a second, 
then disappears.


       Can someone explain these results?


       Thanks,
       Spencer


gridFn <- function(){
   pushViewport(plotViewport())
   grid.text(label='a label')
   popViewport()
   map()
}

library(grid)
library(maps)
gridFn()

png('gridTst.png')
gridFn()
dev.off()


 > sessionInfo()
R version 3.1.0 (2014-04-10)
Platform: i386-w64-mingw32/i386 (32-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grid      stats     graphics  grDevices utils     datasets methods
[8] base

other attached packages:
[1] maps_2.3-7

loaded via a namespace (and not attached):
[1] tools_3.1.0
 >



More information about the R-help mailing list