Some users like zebra striping in grids (see this ux posting in SE, whence I got the image below).

Example of zebra-striped grid

Of course, it's easy to manually shade and style the cells of a Grid in Mathematica (see this documentation and the image below), but the provided options are almost too general and a solution that is 'just general enough' for zebra striping didn't come to me immediately.

Zebra striping seems like such a common practice that I was rather surprised not to see any examples or mention of it in the documentation, let alone a top-level option for it in Grid. Before diving in, I thought I'd quickly ask the community for an "elegant" solution. Of course, elegant is difficult to define, but you all probably know it when you see it.

enter image description here

  • 2
    $\begingroup$ This is in the docs for Grid. $\endgroup$ – Michael E2 Nov 5 '16 at 18:28

Does this work?

Grid[RandomInteger[1, {5, 4}], 
  Background -> {None, {Lighter[Blue, .9], {White, GrayLevel[.9]}}}, 
  Dividers -> All

enter image description here

| improve this answer | |
  • $\begingroup$ Great to have this as a concrete example of how to program the abstract specs in the documentation. $\endgroup$ – Reb.Cabin Nov 5 '16 at 16:46
  • $\begingroup$ @Reb.Cabin I actually adapted this example from the second example in the Applications section. $\endgroup$ – Chip Hurst Nov 5 '16 at 16:47
  • $\begingroup$ Oh, nice! I missed that one. $\endgroup$ – Reb.Cabin Nov 5 '16 at 17:21

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.