MathGroup Archive 2005

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

Search the Archive

Re: plot on condition

  • To: mathgroup at smc.vnet.net
  • Subject: [mg56253] Re: [mg56218] plot on condition
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Wed, 20 Apr 2005 05:31:17 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

 

>-----Original Message-----
>Sent: Tuesday, April 19, 2005 10:56 AM
>Subject: [mg56253] [mg56218] plot on condition
>
>hello
>my question about plotting a list of points but with some 
>condition depends on 
>the status of points in other list;
>pnts={{1,2},{5,4},{3,2},{2,6},{5,3}};
>cnd={7,3,5,8,3};
>the condition is: plot a point in list "pnts" in Blue if the 
>corresponding 
>element in list "cnd" is 3 else plot in Green
>regards
>
>


Define a function for the graphics directives

gd[3] = Sequence[PointSize[.025], Hue[2/3, 1, .7]];
gd[_] = Sequence[PointSize[.015], Hue[1/3, 1, .7]];

...and MapThread


Show[Graphics[{PointSize[.025], 
      MapThread[{gd[#2], Point[#1]} &, {pnts, cnd}]}]]


Of course, in case of only a single graphics directive you need no
Sequence, in case of none, {} is good as well as Sequence[], e.g.:

gd[3] = Sequence[PointSize[.025], Hue[2/3, 1, .7]];
gd[_] = {};

Show[Graphics[{PointSize[.015], Hue[1/3, 1, .7], 
      MapThread[{gd[#2], Point[#1]} &, {pnts, cnd}]}]]


--
Hartmut Wolf


  • Prev by Date: Re: match 1, replace 2
  • Next by Date: Re: holding boxes verbatim
  • Previous by thread: Re: plot on condition
  • Next by thread: Re: plot on condition