[R] shaded area graph and extra plot
jim holtman
jholtman at gmail.com
Tue Feb 12 17:27:26 CET 2008
Use 'xlim=c(1993,2008)' in your second plot to setup the same range.
On Feb 12, 2008 10:39 AM, Luis Ridao Cruz <Luisr at frs.fo> wrote:
> R-help,
>
> I'm using the code below to plot a shaded area graph.
>
> At the same time I want to plot a second series on the y-axis (from
> par(new=T) on)
> but as the two series have different x-axis range (first 1994:2007 and
> second 1996:2007)
> the corresponding x's do not match.
>
> How can this be sorted out?
>
> Thanks in advance
>
> #############################################
> plot.new()
> plot.window(xlim=c(1993,2008), xaxs="i", ylim=c(0,400), yaxs="i")
>
> x=1994:2007
> xx = c(1994, x, 2007)
>
> yy1 = c(0, indexSp[,"Xhat5Sp"]+indexSp[,"seA"], 0 )
> yy2 = c(0, indexSp[,"Xhat5Sp"]-indexSp[,"seA"], 0 )
>
> polygon(xx, yy1, col="grey", lty=0)
> polygon(xx, yy2, col="white", lty=0)
> lines(x, indexSp[,"Xhat5Sp"], type="l")
>
> axis(1)
> axis(2)
>
> par(new=T)
> plot(1996:2007, c(0,0,indexSu[,"Xhat5Su"]), type="p", col=2, lwd=2,
> cex=1,ann=T,axes=F)
> axis(4)
> #############################################
>
> ______________________________________________
> 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem you are trying to solve?
More information about the R-help
mailing list