Your code produces four line graphs, one above the other. What
do you mean by drawing a contour line for the entire panel? A
contour map requires three vectors, two for the horizontal
position and one for the elevation or height. You have four
vectors of y variables with the same x. Since you do not have a
response yet, I am apparently not the only one who is confused
by your question.
-------------------------------------
David L Carlson
Department of Anthropology
Texas A&M University
College Station, TX 77840-4352
-----Original Message-----
From: r-help-bounces at r-project.org
[mailto:r-help-bounces at r-project.org] On Behalf Of catalin roibu
Sent: Wednesday, February 19, 2014 9:48 AM
To: r-help at r-project.org
Subject: [R] multiplot contour
Dear R users,
I have a multiplot graph in R (in the following code), but I
don't know how
to make (draw ) a contour line for entire multipanel.
Please help me to solve this problem.
Thank you very much!
#Generate the data for the four graphs
x <- seq(1, 50, 1)
y1 <- 10*rnorm(50)
y2 <- 100*rnorm(50)
y3 <- 1000*rnorm(50)
y4 <- 10000*rnorm(50)
#Set up the plot area so that multiple graphs can be crammed
together
par(pty="m", plt=c(0.1, 1, 0, 1), omd=c(0.1,0.9,0.1,0.9))
#Set the area up for 4 plots
par(mfrow = c(4, 1))
#Plot the top graph with nothing in it ========================plot(x, y1,
xlim=range(x), type="n", xaxt="n",axes=F
,yaxt="n",
main="",
xlab="", ylab="")
mtext("Four Y Plots With the Same X", 3, line=1, cex=1.5)
#Store the x-axis data of the top plot so it can be used on the
other graphs
pardat<-par()
xaxisdat<-seq(pardat$xaxp[1],pardat$xaxp[2],(pardat$xaxp[2]-pard
at$xaxp[1])/pardat$xaxp[3])
#Get the y-axis data and add the lines and label
yaxisdat<-seq(pardat$yaxp[1],pardat$yaxp[2],(pardat$yaxp[2]-pard
at$yaxp[1])/pardat$yaxp[3])
axis(4, at=yaxisdat, las=2, padj=0.5, cex.axis=0.8, hadj=0.5,
tcl=-0.3)
#abline(v=xaxisdat, col="lightgray")
#abline(h=yaxisdat, col="lightgray")
mtext("y1", 2, line=2.3)
lines(x, y1, col="red")
#Plot the 2nd graph with nothing
===============================plot(x, y2, xlim=range(x), type="n",
xaxt="n", yaxt="n",
main="",axes=F,
xlab="", ylab="")
#Get the y-axis data and add the lines and label
pardat<-par()
yaxisdat<-seq(pardat$yaxp[1],pardat$yaxp[2],(pardat$yaxp[2]-pard
at$yaxp[1])/pardat$yaxp[3])
axis(2, at=yaxisdat, las=2, padj=0.5, cex.axis=0.8, hadj=0.5,
tcl=-0.3)
#abline(v=xaxisdat, col="lightgray")
#abline(h=yaxisdat, col="lightgray")
mtext("y2", 2, line=2.3)
lines(x, y2, col="blue")
#Plot the 3rd graph with nothing
================================plot(x, y3, xlim=range(x), type="n",
xaxt="n",axes=F, yaxt="n",
main="",
xlab="", ylab="")
#Get the y-axis data and add the lines and label
pardat<-par()
yaxisdat<-seq(pardat$yaxp[1],pardat$yaxp[2],(pardat$yaxp[2]-pard
at$yaxp[1])/pardat$yaxp[3])
axis(4, at=yaxisdat, las=2, padj=0.5, cex.axis=0.8, hadj=0.5,
tcl=0.3)
#abline(v=xaxisdat, col="lightgray")
#abline(h=yaxisdat, col="lightgray")
mtext("y3", 2, line=2.3)
lines(x, y3, col="green")
#Plot the 4th graph with nothing
================================plot(x, y4, xlim=range(x), type="n",
xaxt="n",axes=F, yaxt="n",
main="",
xlab="", ylab="")
#Get the y-axis data and add the lines and label
pardat<-par()
yaxisdat<-seq(pardat$yaxp[1],pardat$yaxp[2],(pardat$yaxp[2]-pard
at$yaxp[1])/pardat$yaxp[3])
axis(2, at=yaxisdat, las=2, padj=0.5, cex.axis=0.8, hadj=0.5,
tcl=-0.3)
#abline(v=xaxisdat, col="lightgray")
#abline(h=yaxisdat, col="lightgray")
mtext("y4", 2, line=2.3)
lines(x, y4, col="darkgray")
#Plot the X axis
================================================axis(1, at=xaxisdat, padj=-1.4,
cex.axis=0.9, hadj=0.5,
tcl=-0.3)
mtext("X Variable", 1, line=1.5)
--
---
Catalin-Constantin ROIBU
Lecturer PhD, Forestry engineer
Forestry Faculty of Suceava
Str. Universitatii no. 13, Suceava, 720229, Romania
office phone +4 0230 52 29 78, ext. 531
mobile phone +4 0745 53 18 01
+4 0766 71 76 58
FAX: +4 0230 52 16 64
silvic.usv.ro
[[alternative HTML version deleted]]
______________________________________________
R-help at r-project.org 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.