2

I have just started with R and now I am trying to plot the amount of months with information per year in each station by using matrixplot function as following:

a <- dwi(Monthly_data[,1:54], out.unit = "years", dates=1)

matrixplot(a, var.type ="Days", main="Number of months with info per year")

and I get the plot with the scale, on the color bar, from 2-12. enter image description here

I want to change the scale on the colorbar to 0-12. I tried with xlim and ylim but they both don't work on the colorbar. Please give me any suggestion. Thank you.

Amir
  • 10,600
  • 9
  • 48
  • 75
  • Welcome to StackOverflow. A [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) would be helpful – polka Dec 07 '15 at 18:56

1 Answers1

0

I hope this is what you are looking for:

require(hydroTSM)
data(EbroPPtsMonthly)
Monthly_data <- EbroPPtsMonthly  
a <- dwi(Monthly_data[,1:54], out.unit = "years", dates=1)
cols = colorRampPalette(c("red", "green"))
matrixplot(
      x = a
    , main="Number of months with info per year"
    , ColorRamp = cols
    , at = c(0,1,2,3,4,5,6,7,8,9,10,11,12)
    , colorkey = list(
          at=seq(from=0, to=12, by=1)
        , labels = c("0","1","2","3","4","5","6","7","8","9","10","11","12")
        , col = cols
    )
)

Let's continue counting rain drops... 555