Quantcast

several Filled.contour plots on the same device...

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

several Filled.contour plots on the same device...

Alexis.berg


hello -

a question about filled.contour plots, for which i haven't found a
response in previous posts - sorry if already treated.

i'd like to draw several filled.contour plots (that is, maps) on the same
device (a postscript file, actually). I know about layout(matrix) ,
split.screen or par(mfrow) : it works well for simple plots, but with
filled.contour plots, i get several pages instead of one page divided into
several cells.
I'd really like to get these maps directly on one graphs, without having
to process them afterwards.
Does anyone know something about that ?

Thank you for your help,

Alexis Berg

Ingénieur de recherche
LOCEAN (IPSL) - Paris
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: several Filled.contour plots on the same device...

Gregory Snow
The problem is that filled.contour uses the layout function internally which messes up any other use of layout, split.screen, or mfrow.  One alternative is to use the levelplot function from the lattice package, or you could use filled.contour to make several full page plots to a pdf file, then use an external utility like pdfpages to combine them onto a single page.

Hope this helps,

--
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
[hidden email]
(801) 408-8111
 
 

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> [hidden email]
> Sent: Thursday, February 22, 2007 4:15 AM
> To: [hidden email]
> Subject: [R] several Filled.contour plots on the same device...
>
>
>
> hello -
>
> a question about filled.contour plots, for which i haven't
> found a response in previous posts - sorry if already treated.
>
> i'd like to draw several filled.contour plots (that is, maps)
> on the same device (a postscript file, actually). I know
> about layout(matrix) , split.screen or par(mfrow) : it works
> well for simple plots, but with filled.contour plots, i get
> several pages instead of one page divided into several cells.
> I'd really like to get these maps directly on one graphs,
> without having to process them afterwards.
> Does anyone know something about that ?
>
> Thank you for your help,
>
> Alexis Berg
>
> Ingénieur de recherche
> LOCEAN (IPSL) - Paris
> [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
> and provide commented, minimal, self-contained, reproducible code.
>

______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: several Filled.contour plots on the same device...

Billy.Requena
Hi Alexis!

I had the same problem you faced and the solution I found was modifying the layout function.
That’s an example:

f1 <- function (a, x) {2.15*a -0.25*x}
f2 <- function (a,x) {exp(2.36*a - 0.04*x)}
a1 <- seq(from=5.2, to=6.2, by=(6.2-5.2)/19)
b1 <- seq(0,32)
zeros <- rep(0, length(a)*length(b))
mat1 <- matrix(zeros, ncol=length(a), nrow=length(b))
 for (i in 1:20)
 {
 for(j in 1:33)
 {
 est <- f1(a=a1[i], x=b1[j])
 mat1[j,i] <- est
 }
 }

mat2 <- matrix(zeros, ncol=length(a), nrow=length(b))
 for (i in 1:20)
 {
 for(j in 1:33)
 {
 est <- f2(a=a1[i], x=b1[j])
 mat2[j,i] <- est
 }
 }


mar.orig <- (par.orig <- par(c("mar", "las", "mfrow")))$mar
w <- (3 + mar.orig[2L]) * par("csi") * 2.54
a <- layout(matrix(c(2, 1,0,4,3), ncol = 5), heights=lcm(20), widths = c(1.2, lcm(w/1.75),0.05, 1, lcm(w/1.75)))
layout.show(a) #device dividido ppara apresentar duas figuras compostas

#Scale 1
par(las = 1)
mar <- mar.orig
mar[4L] <- mar[2L]
mar[2L] <- 1
par(mar = mar)
lev.m.vol <- pretty(range(mat1),4)
plot.new()
        plot.window(xlim=c(0, 1), ylim=range(lev.m.vol), xaxs="i", yaxs="i")
        rect(0, lev.m.vol[-length(lev.m.vol)], 1, lev.m.vol[-1L], col = gray((6:1)/6))
        axis(4, cex.axis=1.2)
        mtext("Mean", at=2.5, side=3, line=1, adj=1, cex=1.35)

#Graph1
mar <- mar.orig
mar[4L] <- 1
par(mar = c(6,8,4,2))
plot.new()
        plot.window(xlim=range(b1, finite = TRUE), ylim=range(a1, finite = TRUE),
                "", xaxs = "i", yaxs = "i", asp = NA)
        storage.mode(mat1) <- "double"
        .Internal(filledcontour(as.double(b1), as.double(a1), mat1,
                as.double(lev.m.vol), col = gray((6:1)/6)))
box()
axis(1, at=seq(0,32,by=4),seq(0, 32, by =4), cex.axis=1.2)
axis(2, at=seq(5.2, 6.2, by =0.2),labels=c("5.2", "5.4", "5.6", "5.8", "6.0", "6.2"), cex.axis=1.2)
mtext("X", side=1, line=3.5, cex =1.2)
mtext("Y", at=5.62, side=2, line=3.5, cex =1.2, las=0)
mtext("A", at=1, side=3, line=1, cex =2.2)

#Scale 2
par(las = 1)
mar <- mar.orig
mar[4L] <- mar[2L]
mar[2L] <- 1
par(mar = mar)
lev.sd.vol <- pretty(range(mat2),4)
plot.new()
        plot.window(xlim=c(0, 1), ylim=range(lev.sd.vol), xaxs="i", yaxs="i")
        rect(0, lev.sd.vol[-length(lev.sd.vol)], 1, lev.sd.vol[-1L], col = gray((6:1)/6))
        axis(4, cex.axis=1.2)
        mtext("Standard", at=3.3, side=3, line=2.5, adj=1, cex=1.25)
        mtext("deviation", at=3.3, side=3, line=1, adj=1, cex=1.25)

#Graph2
mar <- mar.orig
mar[4L] <- 1
par(mar = c(6,1,4,2))
plot.new()
        plot.window(xlim=range(b1, finite = TRUE), ylim=range(a1, finite = TRUE),
                "", xaxs = "i", yaxs = "i", asp = NA)
        storage.mode(mat2) <- "double"
        .Internal(filledcontour(as.double(b1), as.double(a1), mat2,
                as.double(lev.sd.vol), col = gray((6:1)/6)))
box()
axis(1, at=seq(0,32,by=4),seq(0, 32, by =4), cex.axis=1.2)
axis(2, at=seq(5.2, 6.2, by =0.2),labels=c("5.2", "5.4", "5.6", "5.8", "6.0", "6.2"), cex.axis=1.2)
mtext("X", side=1, line=3.5, cex =1.2)
mtext("B", at=1, side=3, line=1, cex =2.2)

I wish it could help you

Gustavo Requena
PhD student - Laboratory of Arthropod Behavior and Evolution
Universidade de São Paulo
http://ecologia.ib.usp.br/opilio/gustavo.html
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: several Filled.contour plots on the same device...

sunaj
Billy.Requena,
I bow myself into the dust - exactly what I was looking for.
Thx,
Sunaj
Loading...