[R] Why is bubbles() creating empty png graphs?

Roger Bivand Roger.Bivand at nhh.no
Thu Dec 15 12:45:37 CET 2005


On Thu, 15 Dec 2005, Rainer M Krug wrote:

> This code below produces empty XXX.png files - if I use plot(), it works 
> and if I enter the commands
> 
> png(filename=fn)
> bubble(positions, do.sqrt=FALSE, main=q)
> dev.off()
> 
> manually, it works as well.

This a hidden FAQ 7.22: Why do lattice/trellis graphics not work?

bubble() in package sp or gstat calls lattice function xyplot internally, 
so doing print(bubble(...)) should work.

> 
> I am lost - any help appreciated.
> 
> The weird thing is that it worked before I made some changes... (I don't 
> have a copy of the working version...).
> 
> R version:
> 
> platform i686-pc-linux-gnu
> arch     i686
> os       linux-gnu
> system   i686, linux-gnu
> status
> major    2
> minor    2.0
> year     2005
> month    10
> day      06
> svn rev  35749
> language R
> 
> Operating system: SuSE 10
> 
> Rainer
> 
> 
> -----------------
> 
> library(gstat)
> library(RMySQL)
> library(DAAG)
> 
> m <- dbDriver("MySQL")
> con <- dbConnect(m, group = "renpatch_renosterbos")
> 
> tbls <- dbListTables(con)
> runs <- 1:5
> years <- seq(98, 0, -7)
> 
> progress_end <- length(tbls) * length(runs) * length(years)
> progress <- 0
> 
> for (year in years)
> {
> fd <- paste("/home/rkrug/Documents/R/plots/Y", year, sep="")
> dir.create(fd, showWarnings=FALSE, recursive = TRUE)
> for (run in runs)
> {
> for (tn in tbls)
> {
> fn <- paste(fd, "/", tn, "_R", run, "_Y", year, ".png", sep="")
> progress <- progress + 1
> cat(progress, 'of', progress_end, " | ", fn, " | ")
> flush.console()
> if (!file.exists(fn))
> {
> q <- paste("select X,Y,RX from", tn, "where (_run=", run, ") AND 
> (_Year=", year, ")")
> rs <- dbSendQuery(con, q)
> positions <- fetch(rs, n = -1)
> while (!dbHasCompleted(rs))
> {
> cat(".")
> flush.console()
> }
> cat(length(positions$X), "points")
> png(filename=fn)
> bubble(positions, do.sqrt=FALSE, main=q)
> #plot(positions)
> dev.off()
> pause()
> cat(" | Done \n")
> }
> }
> }
> }
> 
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list