Skip to content

Problems with combining plots

5 messages · Wills, Kellie, johnhj, Baptiste Auguie

#
Hii,

I will combine some plots. Like this example here
http://www.statmethods.net/advgraphs/layout.html I tired to do it for 2
plots but without success.

Here is my code:

test<-read.table(file="D:/file.txt")
space<-read.table(file="D:/space.txt")

space$gruppe <- 502*rep(1:6, each=7)
x<- c(test$V1)
y<- c(test$V2)

par(mfrow=c(1,1)) 

png(filename = "D:/example.png", width = 640, height = 480, pointsize = 12,
bg = "white",  res = NA)

boxplot(V2 ~ gruppe , data = space , col = "lightgray",boxwex=0.2)
plot(panel.first=grid(ny=NULL,nx=NULL),x,y, xlab = "Zeit(sec)", ylab
="Datenrate(MBit(sec))",ylim=c(0,40), col ="purple", type ="l", main
="combined plots",lwd=2)

dev.off()


What is the mistake in my code ?
#
par(mfrow=c(1,1)) will give you just one panel.  Try par(mfrow=c(2,1)) or par(mfrow=c(1,2)).


-----Original Message-----
From: r-help-bounces at r-project.org on behalf of johnhj
Sent: Sun 3/22/2009 10:50 AM
To: r-help at r-project.org
Subject: [R]  Problems with combining plots
 

Hii,

I will combine some plots. Like this example here
http://www.statmethods.net/advgraphs/layout.html I tired to do it for 2
plots but without success.

Here is my code:

test<-read.table(file="D:/file.txt")
space<-read.table(file="D:/space.txt")

space$gruppe <- 502*rep(1:6, each=7)
x<- c(test$V1)
y<- c(test$V2)

par(mfrow=c(1,1)) 

png(filename = "D:/example.png", width = 640, height = 480, pointsize = 12,
bg = "white",  res = NA)

boxplot(V2 ~ gruppe , data = space , col = "lightgray",boxwex=0.2)
plot(panel.first=grid(ny=NULL,nx=NULL),x,y, xlab = "Zeit(sec)", ylab
="Datenrate(MBit(sec))",ylim=c(0,40), col ="purple", type ="l", main
="combined plots",lwd=2)

dev.off()


What is the mistake in my code ?
#
I have still the same problem... As you said I tried with par(mfrow=c(2,1))
and par(mfrow=c(1,2)) but without success. Could R compiler be the problem ?
Wills, Kellie wrote:

  
    
#
On 23 Mar 2009, at 11:52, johnhj wrote:

            
Why not? But may I suggest you try first the following example I sent  
you yesterday,
Does this not produce two plots on a single page?


baptiste


PS: please do read the posting guide

            
_____________________________

Baptiste Augui?

School of Physics
University of Exeter
Stocker Road,
Exeter, Devon,
EX4 4QL, UK

Phone: +44 1392 264187

http://newton.ex.ac.uk/research/emag
#
Hii baptiste,

I tried you example, but I get still one plot and not as you said two plots
...
I use R for Windows, could this have something to do with this problem ?
baptiste auguie-2 wrote: