I'm using the following code to draw plots of two different data on same graph. And it is working well. But the problem is I'm manually scaling the data. Is it possible to autoscale them?
Here is my script
gales <- read.table("input", header=TRUE)
attach(gales)
par(mar=c(5,4,4,4)+0.1)
plot(year,number,type="l",lwd=2,las=1, col="red")
title(main = list("Title", cex=1.5,
col="red", font=3))
par(new=T)
plot(year,feb,type="l",lwd=2, las=1,axes=F,ylab="",col="blue")
axis(4,las=1)
mtext(side=4,line=2.5,"feb")
Here is my data
year number feb
1950 600 20
1951 1200 5
1952 900 5
1953 800 5
1954 800 5
1955 1100 20
1956 600 6
1957 900 10
1958 1200 20
1959 1200 20
1960 800 6
1961 900 6
1962 800 10
1963 1200 20
1964 900 15
1965 600 10
1966 600 10
1967 600 10
1968 600 10
1969 600 10
1970 1200 20
gales <- structure(list(
year = 1950:1970,
number = c(600L, 1200L, 900L, 800L, 800L, 1100L, 600L, 900L, 1200L, 1200L, 800L, 900L, 800L, 1200L, 900L, 600L, 600L, 600L, 600L, 600L, 1200L),
feb = c(20L, 5L, 5L, 5L, 5L, 20L, 6L, 10L, 20L, 20L, 6L, 6L, 10L, 20L, 15L, 10L, 10L, 10L, 10L, 10L, 20L)),
.Names = c("year", "number", "feb"), class = "data.frame", row.names = c(NA, -21L)
)