I have got a data frame like this:
Days Ahm5
01/06/1961 0.00000
02/06/1961 0.19266
03/06/1961 1.67610
........ ........
30/09/1961 5.26514
01/06/1962 0.05200
......... ........
30/09/2007 0.866473
Here's the data:https://www.dropbox.com/s/de88gqk7kvb1q9i/data.csv?dl=0 When I try a scatter plot like,
data <- read.csv("data.csv")
data[data==-9.99e+08] = NA
data$days <- as.Date(data$days, format="%d/%m/%Y")
plot(Ahm5~days,data, col='blueviolet', type="p", pch=1 ,cex=.5, xlab="Year",xaxt='n', ylab="Rainfall(mm/Day)")
axis.Date(side=1,seq(as.Date("1961/1/1"), by = "year", length.out = 47))
But my desired output should be like figure given below with x axis span from 1960 to 2007 as in the data:
Also how to add last year on x axis? Excuse me for this trivial question.
You have to make sure the plot is wide enough, else some of the breaks will be omitted. See the examples below to see the difference.
Example 1:
gives:
Example 2:
gives:
Example 3:
gives:
As you can see the breaks differ between the plots and R chooses which breaks to use. To have nicer breaks, you can use:
which gives:
Now you have:
UPDATE: A further elaboration on the last example:
which gives: