[R] Superimposing 2 curves on the same graph with par(new=TRUE)

varin sacha varinsacha at yahoo.fr
Mon Mar 23 16:54:37 CET 2015


Dear R-Experts,

I try to superimpose/present 2 curves/plots on the same graph. I would like the result/graph to be readable.
For that, I use the par(new=TRUE) argument but on the Y-axis there is a superposition of writings and the Y-axis becomes unreadable.
How can I solve this problem ?

Here is a reproducible example :
Date<-c(1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010)
 
MORTSFr<-c(16445,17671,18113,17043,14738,14355,15028,14283,13229,13603,13672,13547,13527,13021,12737,11388,11947,10742,11497,11476,11215,10483,9900,9568,9019,8891,8541,8444,8918,8487,8079,8160,7655,6058,5593,5318,4709,4620,4275,4273,3992)
 
MORTSBu<-c(838,889,934,946,960,1030,1021,1040,1153,1149,1199,1219,1229,1123,1119,1113,1070,1153,1153,1280,1567,1114,1299,1307,1390,1264,1014,915,1003,1047,1012,1011,959,960,943,957,1043,1006,1061,901,776)
 
plot(Date,MORTSFr,type="l")
par(new=TRUE)

plot(Date,MORTSBu,lwd=2,lty="dashed")

Thanks for your time.
Best,
S



More information about the R-help mailing list