I have a time series data which I have converted to a matrix (168,11).
wc0086 <- matrix(d0086$c0086ts[1:1848],168,11)
Then, I can change the row names to weekdays as follows:
time_index1 <- seq(from = as.POSIXct("2017-01-02 00:00", tz = 'UTC'), to = as.POSIXct("2017-01-08 23:00", tz = 'UTC'), by = "hour")
wdays <- weekdays(time_index1)
wdays <- as.factor(weekdays(time_index1))
row.names(wc0086) <- wdays
Then, I am trying to draw a matplot of wc0086.
matplot(wc0086, type="l")
The problem is that the x-axis showing the the values from 1 to 168 (the number of rows of the matrix. I want to show the weekdays(Monday to Sunday).
Thanks
Perhaps something like this:
matplot(wc0086, type="l", xaxt='n')
axis(side=1, at=1:168, labels=wdays)
This may create an x-axis tick for every day, which you might not want, but you might be able to play with subsetting the at=
and labels=
arguments.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.