lanc...@fns.uniba.sk schrieb: > Good day, > > I'm trying to get more time series in one plot. As there are bigger > differences in values of variables I need logaritmic y axis. > > The code I use is the following: > > nvz_3_data <- read.csv('/home/tomas/R_outputs/nvz_3.csv') > date <- (nvz_3_data$date) > NO3 <- (nvz_3_data$NO3) > NH4 <- (nvz_3_data$NH4) > date_p <- as.POSIXct(date, "CET") > par(mfrow=c(2,1), ylog = TRUE, yaxp = c(0.01, 100, 3)) > plot(date_p, NO3, log = "y", type = "l", col = "darkred", main = "NVZ-1", > xlab = "time", ylab = "NO3-" ) > lines(date_p, NH4, col = "darkblue", lty = "dotted") > plot(date_p, NH4, log = "y", type = "l", col = "darkblue", main = "NVZ-1", > xlab = "time", ylab = "NH4+" ) > > So, as I anderstood, extreme (max and min) values on the y axis are > conntrolled byt the yaxp, but it is ignored on the plot, and the NH4 > values are out of the plot (see the attached picture). Do somebody know > what I am doing wrong? > > Many thanks in advance > > Tomas > > > > ------------------------------------------------------------------------ > > ------------------------------------------------------------------------ > > ______________________________________________ > R-help@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. > Hey Thomas,
the yaxp command isn't ignored. The problem is the boundary of your y-data. Your plot is adjusted to the NO3 data and because the higher values of your NH4 you won't be able to see it on the plot. A solution lies in implementing the ylim command in your plot. Here is your changed code: nvz_3_data <- read.csv('/home/tomas/R_outputs/nvz_3.csv') date <- (nvz_3_data$date) NO3 <- (nvz_3_data$NO3) NH4 <- (nvz_3_data$NH4) maxy<-max(NO3,NH4) ## the maximum value of your data miny<-min(NO3[NO3>0],NH4[NH4>0]) ## the minimum value of your data which are > 0 (because: log) date_p <- as.POSIXct(date, "CET") par(mfrow=c(2,1), ylog = TRUE, yaxp = c(0.01, 100, 3)) plot(date_p, NO3,log = "y", ylim=c(miny,maxy), type = "l", col = "darkred", main = "NVZ-1", xlab = "time", ylab = "NO3-" ) lines(date_p, NH4, col = "darkblue", lty = "dotted") plot(date_p, NH4, log = "y", type = "l", col = "darkblue", main = "NVZ-1", xlab = "time", ylab = "NH4+" ) I hope, I was able to help you. Regards, Christian
signature.asc
Description: OpenPGP digital signature
______________________________________________ R-help@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.