I would like to build each row of this matrix on a separate chart in the graphics window.
mat <- structure(c("g", "b", "c", "e", "g", "b", "g", "g", "e", "e", "a", "b", "b", "e", "c", "f", "d", "f", "g", "c", "f", "g", "b", "e", "a", "b", "c", "a", "c", "g", "c", "d", "e", "d", "b", "f", "e", "f", "a", "f", "c", "f", "e", "f", "d", "d", "f", "a", "d", "f"), .Dim = c(5L, 10L)) # [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #[1,] "g" "b" "a" "f" "f" "b" "c" "f" "c" "d" #[2,] "b" "g" "b" "d" "g" "c" "d" "e" "f" "f" #[3,] "c" "g" "b" "f" "b" "a" "e" "f" "e" "a" #[4,] "e" "e" "e" "g" "e" "c" "d" "a" "f" "d" #[5,] "g" "e" "c" "c" "a" "g" "b" "f" "d" "f"
In response to my post yesterday, I need to first convert this matrix to numeric.
v <- as.character(mat) lev <- sort(unique(v)) ## sorted unique labels # [1] "a" "b" "c" "d" "e" "f" "g" mat_int <- matrix(match(v, lev), nrow = nrow(mat)) # [,1] [,2] [,3] [,4] [,5] [,6] [,7] [,8] [,9] [,10] #[1,] 7 2 1 6 6 2 3 6 3 4 #[2,] 2 7 2 4 7 3 4 5 6 6 #[3,] 3 7 2 6 2 1 5 6 5 1 #[4,] 5 5 5 7 5 3 4 1 6 4 #[5,] 7 5 3 3 1 7 2 6 4 6
Now I use the following code to generate my graph.
par(mfrow=c(5,1)) matplot(t(mat_int)[, c(1)], yaxt = "n", type = "l", xlab = "time", ylab = "category") axis(2, seq_along(lev), labels = lev) matplot(t(mat_int)[, c(2)], yaxt = "n", type = "l", xlab = "time", ylab = "category") axis(2, seq_along(lev), labels = lev) matplot(t(mat_int)[, c(3)], yaxt = "n", type = "l", xlab = "time", ylab = "category") axis(2, seq_along(lev), labels = lev) matplot(t(mat_int)[, c(4)], yaxt = "n", type = "l", xlab = "time", ylab = "category") axis(2, seq_along(lev), labels = lev) matplot(t(mat_int)[, c(5)], yaxt = "n", type = "l", xlab = "time", ylab = "category") axis(2, seq_along(lev), labels = lev)

But I have a few questions:
- The y-axis label for each of the five graphs contains only partial results (for example, βaβ is missing in the second section). Is there a way we can list all categorical variables along the y axis for all five graphs? (That is, each plot has labels: a, b, c, d, e, f, g.
- Now I have to create this graph on a large page to clearly display all the labels on the y axis. Is there a way to arrange my sites closer together to save space so that they can fit on a smaller page?
Thanks.