problem plotting in a grid

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

problem plotting in a grid

hedelhusk
Hi all,
    I'm trying to generate a grid of four plots.  The first 2 appear
just fine, but the final 2 will not appear in the grid, instead
overwriting the first two.    Any ideas on how to get them all in the
same window would be greatly appreciated.

Cheers,
Jonathan

library(fields)

par(mfrow=c(2,2)) #2x2 plot windows
plot(c(2,4),c(2,2))  # works fine
plot(c(2,4),c(2,2))  # works fine

  x <- 1:4
  y <- 5:10
  z <- matrix(0,length(x),length(y))
  z2 <- matrix(0,length(x),length(y))
  for(i in 1:length(x))
  {
    for (j in 1:length(y))
    {
        z[i,j] <- sample(4:10,1)
        z2[i,j] <- sample(4:10,1)
    }
  }

  filled.contour(x,y,z,color.palette=topo.colors)  # doesn't work
  image.plot(x,y,z2,add=TRUE)  # doesn't work

______________________________________________
[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
|

Re: problem plotting in a grid

Jeff Newmiller
Did you actually read the help file for filled.contour?

The image.plot call is being affected by the documented behavior of filled.contour.

ggplot might be worth investigating.
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<[hidden email]>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
---------------------------------------------------------------------------
Sent from my phone. Please excuse my brevity.

Jonathan <[hidden email]> wrote:

>Hi all,
>    I'm trying to generate a grid of four plots.  The first 2 appear
>just fine, but the final 2 will not appear in the grid, instead
>overwriting the first two.    Any ideas on how to get them all in the
>same window would be greatly appreciated.
>
>Cheers,
>Jonathan
>
>library(fields)
>
>par(mfrow=c(2,2)) #2x2 plot windows
>plot(c(2,4),c(2,2))  # works fine
>plot(c(2,4),c(2,2))  # works fine
>
>  x <- 1:4
>  y <- 5:10
>  z <- matrix(0,length(x),length(y))
>  z2 <- matrix(0,length(x),length(y))
>  for(i in 1:length(x))
>  {
>    for (j in 1:length(y))
>    {
>        z[i,j] <- sample(4:10,1)
>        z2[i,j] <- sample(4:10,1)
>    }
>  }
>
>  filled.contour(x,y,z,color.palette=topo.colors)  # doesn't work
>  image.plot(x,y,z2,add=TRUE)  # doesn't work
>
>______________________________________________
>[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.