[R--gR] automating xlim, ylim
Pablo G Goikoetxea
pablo.goiko at gmail.com
Mon Oct 24 13:11:53 CEST 2016
Dear members
I am new to the list and hope this has not been discussed before. I have
repeatedly Google for a solution (using different searches), but have been
unable to find an answer.
Just in case of being of interest, I am working with ABCtoolbox 2.0
I want to plot 29 density plots to compare Parameter Estimation by two
methods (GLM and rejection). Here is my working script:
ABC_GLM <- read.delim("·myfile1.txt") # data from the ABC-GLM estimates. It
contains parameters + parameter densities variables
ABC_re j<- read.delim("myfile2.txt") # data from the ABC-rejection
estimate. It only contains the parameters.
params <- names(ABC_rej)
pdf("paramEstimates.pdf", height=20, width=15)
par(mfrow=c(6.5)
for (i in 3:31) {
j= 2 *(i-2)
k=(j+1)
dens <- density(ABC_rej[,i])
plot(dens,type="l", col="blue)
lines(ABC_GLM[,j], ABC_GLM[,k],type="l", col="red")
}
dev.off()
---------------------------------------
However, many red plots do not fit neither in the xlim nor ylim from the
blue plots. I do not understand well how the lines command works in this
case, so I can not use xlim=range... or ylim=range...
Therefore, I have defined which I believe to be appropriate xlim and ylim
limits to everlay both plots in each of the 29 sub-plots, such as xlims
var Ne0 Ne1.............Tsplit
from 20 20 1000
to 1000 1000 10000 # indeed, without the firs colum
and ylims
var Ne0 Ne1 Tsplit
from 0 0 0
to 12 12 0.5
After feeding it to R (xlims <- read.table("xlims.txt");and ylims <-
read.table("ylims.txt")
I would like to use something of the kind
for (i in 3:31) {
j= 2 *(i-2)
k=(j+1)
dens <- density(ABC_rej[,i])
plot(dens,xlim=c(xlims[2,i],xlims[3,i]), ylim=c(ylims[2.i],
ylimx[3,i]),type="l", col="blue)
lines(ABC_GLM[,j], ABC_GLM[,k],type="l", col="red")
}
but it fails.
Any possibility this kind of approach could work?
Thanks in advance.
I am using R.3.2.2 on an Ubuntu machine (64-bits) with RStudio.
Pablo
--
-------
Pablo G Goikoetxea
Don Vela 54, 2º izda
01009 Vitoria-Gasteiz (SPAIN)
[[alternative HTML version deleted]]
More information about the R-sig-gR
mailing list