Reputation: 351
I have the following matrix and then I paint it according to intervals as shown below
mdat <- matrix(c(0.25,0.45,0.3, 0.75,0.15,0.62,0.40,0.90,1, 0.45,0.15,0), nrow = 4, ncol = 3, byrow = TRUE)
plot(rep(1:4, 3), mdat, pch=15, cex=2.5,
col=c("red","orange","blue", "green")[findInterval(mdat, c(0,.25,.5,.75, 1.1))])
And it works fine as shown in the image.
But now if I define
dimnames(mdat) <- list( c("row1", "row2", "row3","row4"), c("col1", "col2", "col3"))
I need to change in the plot the values in x axis and in the y axis to be row1..row4 instead of the values 0.0.. 1.0 and col1.. col3 instead of 1.0.. 4.0
Upvotes: 2
Views: 2750
Reputation: 92292
Have you considered doing this with ggplot? just a suggestion...
library(ggplot2)
mdat <- data.frame(Y = c(0.25,0.45,0.3, 0.75,0.15,0.62,0.40,0.90,1, 0.45,0.15,0),
X = factor(c(rep("row1",3), rep("row2",3), rep("row3",3), rep("row4",3))))
mdat$Z <- factor(findInterval(mdat$Y, c(0,.25,.5,.75, 1.1)))
P <- ggplot(mdat, aes(x = X, y = Y)) + geom_point(aes(colour = Z), size = 11)
P + theme(axis.text.y = element_text(size = 20), axis.text.x = element_text(size = 20))
Upvotes: 1