powered by
Add a colour coded horizontal bar representing the state sequence to a plot of (presumably time-series) data.
addStates(states, x=NULL,ybot = axTicks(2)[1], ytop=ybot + (axTicks(2)[2] - axTicks(2)[1])/5,dy = ytop - ybot, greyscale = FALSE,leg = NA, J = length(unique(states)), time.scale = 1, shiftx = 0)
A vector of integers representing the states traversed
The time values where the states are observed ((1:length(states)-shiftx)/time.scale if NULL)
Vertical bottom limit of the bar.
Vertical top limit of the bar.
Height of the bar.
If TRUE produces a bar in greyscale.
Array of state names, if present, produces a legend.
Number of states
Resolution of the timescale
Shift the bar forward or backwards horizontal by shiftx distance.
Soren Hojsgaard sorenh@math.aau.dk
addStates
plot(rnorm(100),type='l') addStates(rep(c(1,2),each=50)) plot(seq(0.01,1,.01),rnorm(100),type='l') addStates(rep(c(1,2),each=50),seq(0.01,1,.01))
Run the code above in your browser using DataLab