robjhyndman / demography

demography package for R
https://pkg.robjhyndman.com/demography
73 stars 25 forks source link

nice legend for graphs #24

Open dutangc opened 8 years ago

dutangc commented 8 years ago

niceleg <- function(n, ylim=c(-10, 2), poly.x=c(112, 114), text.x=104, text.y, text.lab=floor(seq(1816, 2013, length=5))) { col <- rainbow(1.25_n) #used in plot.fds y <- seq(ylim[1], ylim[2], length=2_n+1) for(i in 1:n) polygon(c(poly.x[1],poly.x[1],poly.x[2],poly.x[2]), c(y[2_i-1], y[2_i+1], y[2_i+1], y[2_i-1]), border=NA, col=col[i]) if(missing(text.y)) text.y <- seq(y[2], y[2*n], length=length(text.lab)) text(text.x, text.y, text.lab) }

france <- read.demogdata(file="Mx_1x1.txt", popfile="Exposures_1x1.txt", type="mortality", label="France") plot(france, series="male", main="France, Tx mortalite, Homme") niceleg(length(france$year))