Hi everyone,
I have a matrix of numbers that I want to display as a grid and have the cells containing numbers > 135 highlighted. My approach was to pre-compute the position of the cells to be highlighted, and I'm wondering if there is a slicker way to do it. This is what I did.
(the data)
d = {
{129, 62, 60, 123, 62, 58, 144, 75, 56, 145, 79, 57},
{124, 67, 57, 126, 72, 59, 138, 71, 59, 137, 74, 56},
{132, 69, 62, 119, 67, 61, 125, 66, 62, 122, 67, 65},
{133, 75, 60, 130, 71, 62, 136, 66, 67, 136, 67, 67},
{128, 66, 53, 116, 69, 53, 139, 66, 52, 135, 67, 53},
{121, 64, 57, 118, 67, 58, 134, 71, 54, 136, 72, 56},
{128, 70, 54, 123, 61, 51, 139, 72, 58, 134, 69, 54},
{114, 62, 56, 116, 59, 54, 126, 65, 52, 119, 64, 53},
{125, 65, 57, 122, 65, 54, 130, 63, 63, 131, 62, 61},
{124, 67, 59, 125, 67, 59, 122, 62, 54, 128, 64, 55}
};
(*position of cells with values > 135*)
highlightPos = Position[d, _?(# > 135 &)];
(*the grid*)
Grid[
d,
Background -> {None, None, Map[# -> LightGray &, highlightPos]},
Alignment -> Automatic
]