MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Coloring cells

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83587] Re: [mg83574] Coloring cells
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Sat, 24 Nov 2007 04:05:32 -0500 (EST)
  • Reply-to: hanlonr at cox.net

myData = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};

pos = Position[myData, _?PrimeQ];

Grid[myData,
 Background -> {Automatic, Automatic,
   ((# -> Yellow) & /@ pos)}]

Grid[myData,
 ItemStyle -> {Automatic, Automatic,
   ((# -> Red) & /@ pos)}]

Grid[myData,
 Background -> {Automatic, Automatic,
   ((# -> Yellow) & /@ pos)},
 ItemStyle -> {Automatic, Automatic,
   ((# -> Red) & /@ pos)}]


Bob Hanlon

---- Jamie Coventry <jcoventry at renaissance.edu.hk> wrote: 
> Hi All,
> 
> I'm presenting data in a square arrangement and am trying to  
> highlight specific cells in it which have something in common, e.g.  
> all are prime, or all are odd numbers. I don't mind if the data is in  
> an array/matrix/table, as long as it is n x n.
> 
> myData = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
> 
> How do I either color the text or the background of a particular  
> cell, based on a rule (e.g. how could I color just 2, 3, 5, and 7 in  
> the data given)?
> 
> Thanks in advance,
> 
> Jamie
> 
> 



  • Prev by Date: Plot3D
  • Next by Date: float -> RGB
  • Previous by thread: Re: Coloring cells
  • Next by thread: Plot3D