Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2007

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

Search the Archive

Re: Coloring cells

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83602] Re: [mg83574] Coloring cells
  • From: bsyehuda at gmail.com
  • Date: Sat, 24 Nov 2007 04:13:33 -0500 (EST)
  • References: <fhrrsj$5gh$1@smc.vnet.net> <fhu7ui$7fh$1@smc.vnet.net>

Hi,
Here is a functional programming approach
Map[If[PrimeQ[#], Style[#, Background -> Yellow], #] &, myData, {2}]

and here is a pattern mapping approach
myData /. x_?PrimeQ :> Style[x, Background -> Yellow]

yehuda

On Nov 23, 2007 12:33 PM, 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: Using ListPlot to Plot Lines and Single Points
  • Next by Date: Plot3D
  • Previous by thread: Re: Using ListPlot to Plot Lines and Single Points
  • Next by thread: Re: Coloring cells