I want to plot years versus population and have a very simple R plot given below:
Here is the R code for the plot:
dat <- data.frame(population, year)
year <- c(1518,1523,1569,1642,1871,1872,1873,1874,1875,1876,1877,1894,1897,1898,1899,1900, 1914,1927)
population <- c(753,2407,4414,1800,7896,6594,6594,6594,6594,6594,6615,8583,8583,8583,7470,7540,12266,10573)
offsets <- c(1, with(dat, ifelse(dat$population[-1] < dat$population[- nrow(dat)], -1, 1)))
plot(population ~ year, data=dat, type="l")
points(dat$year, dat$population)
text(dat$year-10, dat$population+500*offsets, labels=round(dat$year,0))
I want years to appear near the small circles. Is that possible? I used identify(year,population)
but that just numbers circles as 1,2,3,..., which is not what I want. Any help?