# creating grid
a.grid <- initGrid(dimension=c(5,5), topo="square", dist.type="maximum")
# plotting grid
# without any color specification
plot(a.grid)
# generating colors from rainbow() function
my.colors <- grDevices::rainbow(5*5)
plot(a.grid) + ggplot2::scale_fill_manual(values = my.colors)
Run the code above in your browser using DataLab