can someone help to change the legend of this graphic to a continuous colour legend, like the legend in the second image.
library(demography)
plot.demogdata(portugal,series='male')
legend("bottomright",legend=unique(portugal$year),
col=rainbow(length(portugal$year)*1.25), ncol=5, pch=19,
title="Year", cex=0.5)
Try this. Not hi-tech, but works well for your need and does not require extra packages. Copy & paste to R console to see how it works.