Skip to content
Prev 393458 / 398500 Next

Reg: To change the x axis label in ts.plot function

Hi Upananda,
First, the date sequence you are using doesn't match the dates you
specify in your post. The code below may give you what you want:

# make up some prices
price<-c(seq(60,25,length.out=25),seq(25,70,length.out=54))+rnorm(79)
pricet <- ts(price, start = as.Date("2020-01-27"),end=as.Date("2021-07-26"),
frequency=1/7)
plot(pricet,xaxt="n")
axis_dates<-as.Date(c("2020-06-30","2021-01-01","2021-06-30"))
axis(1,at=axis_dates,labels=format(axis_dates,"%d/%m/%Y"))

Jim
On Sun, Dec 25, 2022 at 5:58 AM Upananda Pani <upananda.pani at gmail.com> wrote: