lundi 24 mars 2014

Label x and y axis values in plot with matrix cols and rows names


Vote count:

0




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 enter image description here



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire