Suppose I have a matrix object in R with the values:
aa <- matrix(c(0,4,1,10,3,2,1,6,0), ncol=3)
And I want to make a figure like the one in the image, with that scale.
Can anyone help me with a function that can help me to do this type of figure in R? or the name of that type of figure-plot-colored-grid?

Look at the
imagefunction. For the scale you will probably want thecolorscalefunction in the plotrix package. There are other functions that can also be used for these types of graphs:rasterImage,levelplotin the lattice package, etc. You could even create it from scratch using multiple calls torectand other functions if you want complete control. Butimageis probably the quickest/easiest for what you show.