Why is bubbles() creating empty png graphs?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Why is bubbles() creating empty png graphs?

Rainer M Krug
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.

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:    [hidden email]
           [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why is bubbles() creating empty png graphs?

Roger Bivand
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: [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Roger Bivand
Department of Economics
NHH Norwegian School of Economics
Helleveien 30
N-5045 Bergen, Norway
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why is bubbles() creating empty png graphs?

Prof Brian Ripley
In reply to this post by Rainer M Krug
Is this bubble() from gstat?

FAQ, Q7.22

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.
>
> 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:    [hidden email]
>           [hidden email]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

--
Brian D. Ripley,                  [hidden email]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Why is bubbles() creating empty png graphs?

Rainer M Krug
In reply to this post by Roger Bivand
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:    [hidden email]
           [hidden email]

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Loading...