[Basta-users] question about Basta
Owen Jones
jonesor at gmail.com
Sun Dec 25 01:21:36 CET 2011
Hi Felix,
If you are au fait enough with R you can poke around inside the plot.basta function to accomplish this. Here's something I knocked up based on the original function (it's at the end of my email - cut and paste it into R!). I've not tested it extensively but it should work.
Here is an example of use, where I want to plot the 1st and 3rd category (indicated with pz argument), with limits for the mortality plot from 0 to 10, and on the x axis from 0 to 40:
plot.basta2(X,pz=c(1,3),mortylim=c(0,10),xlim=c(0,40))
We'll be developing the functions during the new year so if you have any specific requests let us know! I hope you find this useful in the meantime.
Cheers,
Owen
###
plot.basta2 <-
function(x, pz = NULL, mortylim = NULL,survylim = NULL,...){
Palette <- c("#A6CEE3", "#1F78B4", "#B2DF8A", "#33A02C",
"#FB9A99", "#E31A1C", "#FDBF6F", "#FF7F00",
"#CAB2D6", "#6A3D9A", "#FFFF99", "#B15928")
length.cat <- ncol(x$Zcat)
{
zname <- names(x$Sx)[pz]
length.cat <- length(zname)
if(is.null(pz)) { used.cat <- 1:length.cat}else{ used.cat <- pz}
Bord <- Palette[round(seq(1, 12, length = length(used.cat)))]
Cols <- adjustcolor(Bord, alpha.f = 0.5)
op <- par(mfrow = c(2, 1), mar = c(4, 4, 3, 2))
# Plot survival probability:
mxv <- ceiling(max(unlist(x$xv)) / 5) * 5
plot(x = c(0, mxv),
y = range(0, 1),
col = NA,
xlab = "",
ylab = expression(S(x)),
main = "Survival probability",
frame.plot = FALSE, ...)
for(i in 1:length(used.cat)){
j = pz[i]
xv <- x$xv[[j]]
polygon(x = c(xv, rev(xv)),
y = c(x$Sx[[j]][[1]][, 2, 1], rev(x$Sx[[j]][[1]][, 3, 1])),
col = Cols[i],
border = Bord[i])
lines(x = xv,
y = x$Sx[[j]][[1]][,1,1],
col = Bord[i],
lty = 3)
}
if (length.cat > 1) {
legend(x = 'topright',
legend = zname,
pch = 15,
pt.cex = 3,
cex = 1.25,
col = Cols,
bty = 'n')
}
# Plot mortality rates:
if(is.null(mortylim)){
ylmx <- c(0, round(max(unlist(x$mx))))
}else{
ylmx <- mortylim}
plot(x = c(0,mxv),
y = ylmx,
col = NA,
ylim = ylmx,
xlab = "Age (x)",
ylab = expression(mu(x)),
main = "Mortality rate",
frame.plot = FALSE, ...)
for(i in 1:length(used.cat)){
j = pz[i]
xv <- x$xv[[j]]
polygon(x = c(xv, rev(xv)),
y = c(x$mx[[j]][[1]][,2,1], rev(x$mx[[j]][[1]][,3,1])),
col = Cols[i],
border = Bord[i])
lines(x = xv,
y = x$mx[[j]][[1]][, 1, 1],
col = Bord[i],
lty = 3)
}
par(op)
}
}
On 22 Dec 2011, at 10:16, Felix Zajitschek wrote:
>
>
> -------- Original Message --------
> Subject: Re: question about Basta
> Date: Thu, 22 Dec 2011 10:30:56 +0100
> From: Colchero, Fernando <Colchero at demogr.mpg.de>
> To: Felix Zajitschek <felix.zajitschek at ebc.uu.se>
>
> Hi Felix,
>
> Actually, the plotting functions are pretty rigid... We need to make them a bit more interactive. About the time-dependent covariates, we are working on the code. We are also changing the architecture of the whole package, that's why it's being a bit slow. But I'll let you know as soon as we have a version that can be tested. If you want to post this to the mailing list that'll be ok, I'm pretty sure that anyone that starts using the package will have the same questions.
>
> Thanks a lot for your input and for giving it a try! Best,
>
> Fernando
>
> ______________________________________________
>
> Fernando Colchero
>
> Max Planck Institute for Demographic Research
> Konrad Zuse Str. 1, 18057, Rostock, Germany
> Tel: +49 (0) 381 2081 113
> Fax: +49 (0) 381 2081 529
> E-mail: Colchero at demogr.mpg.de
> ______________________________________________
>
>
>
>
>
> On Dec 20, 2011, at 8:31 PM, Felix Zajitschek wrote:
>
> > Hi Fernando,
> >
> > I wondered whether there is a way to change parameters for the graphic output, e.g. only print a subset of tested groups in one graph, or change the x- and y-axis limits. Do you still plan, btw, to implement time-dependent covariates?
> >
> > Please tell me when you think that I should also post this to the mailing list.
> >
> > Thanks and best regards,
> > Felix
> >
> > On 6/09/2011 1:28 PM, Colchero, Fernando wrote:
> >> Dear Felix,
> >>
> >> Thanks a lot for your interest in the package, by the way, I really liked your paper on sex effects on lifespan in the wild. Well, we are really close to have a working version. There are still a couple of things to clean up, but, if you want, as soon as we're done with this I can send you the link to download the package. I guess it shouldn't take more than two or maximum three weeks.
> >>
> >> Best,
> >>
> >> Fernando
> >>
> >> ______________________________________________
> >>
> >> Fernando Colchero
> >>
> >> Max Planck Institute for Demographic Research
> >> Konrad Zuse Str. 1, 18057, Rostock, Germany
> >> Tel: +49 (0) 381 2081 113
> >> Fax: +49 (0) 381 2081 529
> >> E-mail: Colchero at demogr.mpg.de
> >> ______________________________________________
> >>
> >>
> >>
> >>
> >>
> >> On Sep 6, 2011, at 1:21 PM, Felix Zajitschek wrote:
> >>
> >>> Dear Fernando,
> >>>
> >>> could I ask you whether you already know more about the scheduling of your forthcoming R package Basta?
> >>>
> >>> Best regards,
> >>> Felix
> >>>
> >>> --
> >>> ____________________________________________
> >>> Dr Felix Zajitschek
> >>> Department of Animal Ecology
> >>> Evolutionary Biology Centre
> >>> Uppsala University
> >>> Norbyvägen 18D
> >>> Uppsala, 752 36
> >>> Sweden
> >>> Tel: +46 18 471 2613
> >>> Fax: +46 18 471 6484
> >>>
> >>> Homepage:
> >>> felix.zajitschek.net
> >>>
> >>> Ageing Research Group page:
> >>> http://www.ebc.uu.se/Research/groups/ageing/
> >>> ____________________________________________
> >>>
> >> ----------
> >> This mail has been sent through the MPI for Demographic Research. Should you receive a mail that is apparently from a MPI user without this text displayed, then the address has most likely been faked. If you are uncertain about the validity of this message, please check the mail header or ask your system administrator for assistance.
> >>
> >>
> >
> > --
> > ____________________________________________
> > Dr Felix Zajitschek
> > Department of Animal Ecology
> > Evolutionary Biology Centre
> > Uppsala University
> > Norbyvägen 18D
> > Uppsala, 752 36
> > Sweden
> > Tel: +46 18 471 2613
> > Fax: +46 18 471 6484
> >
> > Homepage:
> > felix.zajitschek.net
> >
> > Ageing Research Group page:
> > http://www.ebc.uu.se/Research/groups/ageing/
> > ____________________________________________
> >
>
> _______________________________________________
> Basta-users mailing list
> Basta-users at lists.r-forge.r-project.org
> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/basta-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/basta-users/attachments/20111225/f593a7ab/attachment.htm>
More information about the Basta-users
mailing list