R - How can I change date format when I plot an xts & zoo object?

*爱你&永不变心* 提交于 2019-12-02 00:04:21

With xts, you can use major.format directly.

plot(price_AAPL, main = "The price of AAPL",major.format="%b-%d-%Y")

However, you should know that zoo plots are generally more flexible.

plot.zoo(price_AAPL, main = "The price of AAPL", xaxt="n", xlab="")
axis.Date(1,at=pretty(index(price_AAPL)),
            labels=format(pretty(index(price_AAPL)),format="%b-%d-%Y"),
            las=2, cex.axis=0.7)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!