3
$\begingroup$

I have a table given by (a simple example for clarity)

Grid[
 MapThread[
  Prepend, {Prepend[
   Table[1, {m, 0, 10}, {x, 0, 10}], {"x=0", "1", "2", "3", "4", "5",
   "6", "7", "8", "9", "10"}], {"Table", "m=0", "1", "2", "3", "4",
   "5", "6", "7", "8", "9", "10"}}],
 Frame -> {{True}, {True}}]/. 1 -> Style[1, Bold, Red]

It's just a grid of 1s with all 1 highlighted in red. But what I want to know is how do I:

  1. Create a downwards-diagonal line across the grid at x=m?
  2. Turn the font style to grey for all items above that line, thus over-riding the Bold, Red instruction (not for values on the line, for values above it - i.e., for all x>m)?

Thanks in advance.

$\endgroup$
  • $\begingroup$ Also, can I then label that line? $\endgroup$ – Richard Burke-Ward Aug 15 '18 at 15:31
2
$\begingroup$

This does some of what you request. Style can be applied at quite low levels of the expression

Grid[MapThread[
  Prepend, {Prepend[
    Table[If[m >= x, Style[1, {Red, Bold}], Style[1, Gray]], {m, 0, 
      10}, {x, 0, 10}], {"x=0", "1", "2", "3", "4", "5", "6", "7", 
     "8", "9", "10"}], {"Table", "m=0", "1", "2", "3", "4", "5", "6", 
    "7", "8", "9", "10"}}], Frame -> {{True}, {True}}]

enter image description here

I don't know how you'd add diagonal lines.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.