Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add legends for rainbow graphs #25

Open
robjhyndman opened this issue Apr 5, 2016 · 0 comments
Open

Add legends for rainbow graphs #25

robjhyndman opened this issue Apr 5, 2016 · 0 comments

Comments

@robjhyndman
Copy link
Owner

library(demography)

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)
  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)
}

plot(fr.mort, series="male", main="France, Tx mortalite, Homme")
niceleg(length(fr.mort$year))
@robjhyndman robjhyndman changed the title Improve legends for graphs Add legends for rainbow graphs Apr 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant