plot time series graph where x shows every year

0

When plotting the normal time series plot (series), some years are understood that exist, but do not appear. Would you have a way to display each year of the time series horizontally on the x axis?

    
asked by anonymous 29.04.2018 / 23:29

1 answer

3

To do what you ask, you have to start by not including the axes with the axes = "n" argument. Then use the axis function to set the axes where and how you want them.

First I'll create a time series, since we do not have data in the question.

set.seed(4745)    # torna os resultados reprodutíveis

x <- ts(rnorm(14), start = 2005, end = 2018)

Now, the chart. Note that even though the years may not fit on the chart. Then I turned 90 degrees to be perpendicular to the x axis. This is done with las = 2 .

plot(x, xaxt = "n")
axis(1, at = 2005:2018, labels = 2005:2018, las = 2)

Chart:

    
30.04.2018 / 07:07