Message Boards Message Boards


Multiple grid position background colouring.

Posted 8 years ago
0 Replies
0 Total Likes

Hi everyone

This may be of interest to some and as the title says it's about multiple grid position background colouring, I could not find any reference to this in the documentation though that doesn't mean it isn't there or mentioned, but there certainly isn't any examples that show this, so here is a method I discovered that does the trick.

n = 15; a = Partition[RandomSample[Range[n^2]], n];
coordinatelist = 
 Partition[RandomChoice[Range[n], 2 RandomInteger[n^2]], 2]; Grid[a, 
 Frame -> All, ItemSize -> Full, Spacings -> {1, 1}, 
 Background -> {Pink, Automatic, 
   Table[i -> Green, {i, coordinatelist}]}]

Of course the coordinate list in this example is a random list, it would of course be whatever list you wanted.


POSTED BY: Paul Cleary
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract