[R] Why is bubbles() creating empty png graphs?
Rainer M Krug
rkrug at sun.ac.za
Thu Dec 15 13:02:59 CET 2005
Thanks a lot for yor help - it is working now
Rainer
Roger Bivand wrote:
> 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")
>> }
>> }
>> }
>> }
>>
>>
>
--
--
Rainer M. Krug, Dipl. Phys. (Germany), MSc Conservation Biology (UCT)
Department of Conservation Ecology
University of Stellenbosch
Matieland 7602
South Africa
Tel: +27 - (0)72 808 2975 (w)
Fax: +27 - (0)21 808 3304
Cell: +27 - (0)83 9479 042
email: RKrug at sun.ac.za
Rainer at krugs.de
More information about the R-help
mailing list