r - small line x-axis for years -


i have data covering time period of on 25 years. in data set on 6300 days. show years on x-axix.

dates <- as.date(dol[,1], "%d.%m.%y") dol <- as.xts(dol[,2], dates)  plot(dol, xaxt = "n", main="sma", ann = false) axis(1, at=as.posixct(dates),labels=format(dates,"%y"),tick=true) title(ylab = "value") title(xlab = "time") 

the graph looks this:

enter image description here

i have single lines @ x axis each year instead of black big bar.

now see mean.

one way handle create 2 time series, , use 1 calculations , plotting data, , other tic marks. this:

library(xts) n <- 1000 d1 <- seq(as.date("2001-01-01"),as.date("2021-01-01"),length.out=n) d1y <- seq(as.date("2001-01-01"),as.date("2021-01-01"),length.out=21) d2 <- rnorm(n,10,1) dollar <- data.frame(d1,d2) dates <- as.date(dollar[,1], "%d.%m.%y",tz="gmt")  xtsplot <- as.xts(dollar[,2], dates) plot(xtsplot, xaxt = "n", main="sma", ann = false) axis(1, at=as.posixct(d1y),labels=format(d1y,"%y")) title(ylab = "value") title(xlab = "time")  

there other ways too...

enter image description here


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -