i new r , trying plot following:
x <- c(1:13) y <- c(19.77, 18.07, 20.55, 16.42, 18.47, 20.18, 22.91, 13.18, 18.07, 17.05, 13.45, 11.11, 22.52) y2 <- c(26.93, 24.5, 25.73, 23.65, 20.50, 29.58, 18.8, 17.38, 12.2, 18.17, 12.55, 15.63, 26.07) par(mar=c(5,7,5,3), pch=22, col="black") plot(x, y2, main="title", xaxt = "n", xlab='', yaxt = "n", ylab = "", type="b", col="blue") par(new = true) plot(x, y, xaxt = "n", xlab='', yaxt = "n", ylab = "", type="b", col="cyan", pch=21) range <- seq(0, 30, 1) axis(1, at=x, labels=x) axis(2, at=range, labels=range, las=1) mtext(side = 1, text = "x", line = 3, col="black") mtext(side = 2, text = "tiempo", line = 5, xpd=false, col="black") # legend. legend(x= "bottomleft", y=0.92, legend=c("exp1","exp2"), col=c("cyan", "blue"), pch=c("_","_")) it plots ok, follows:

however, feel y axis not correlating real values. example, in data (y , y2) can see 1 of maximum values 26.93 in data, highest value around 23 according plot.
i have been playing range variable still haven't found way correct this. google has been of no since not sure how should search problem. of have idea of doing wrong?
also, want values range 0 30, not 11 23. maybe related problem.
any tip valuable! in advance.
staying close possible code, change lines #5 , #7 this:
plot(y2 ~ x, main="title", xaxt = "n", xlab='', yaxt = "n", ylab = "", type = "b", col = "blue", ylim = c(0,30)) lines(y ~ x, xaxt = "n", xlab = '', yaxt = "n", ylab = "", type = "b", col = "cyan", pch = 21) 
Comments
Post a Comment