RE: color of an implicit plot
- To: mathgroup at smc.vnet.net
- Subject: [mg42837] RE: [mg42816] color of an implicit plot
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Wed, 30 Jul 2003 19:30:30 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
>-----Original Message----- >From: Vladimira Ilieva [mailto:vilieva at dreman.com] To: mathgroup at smc.vnet.net >Sent: Wednesday, July 30, 2003 10:08 AM >To: mathgroup at smc.vnet.net >Subject: [mg42837] [mg42816] color of an implicit plot > > >I would really appreciate it if someone lets me know how to >change the color of an implicit plot. Thank you very much! > Perhaps I don't quite understand, 'change the color'. Help tells how to color the lines, e.g. In[1]:= << Graphics`ImplicitPlot` In[3]:= ip = ImplicitPlot[{(x^2 + y^2)^2 == (x^2 - y^2), (x^2 + y^2)^2 == 2 x y}, {x, -2, 2}, PlotStyle -> {{Thickness[.01], GrayLevel[0], Dashing[{.03}]}, RGBColor[0, 0, 1]}] Now I assume you have got the Graphics, but don't want to recalculate it with other styles. So the idea is to (1) locate the graphics directives within the graphics (2) recognize different lines (3) delete the old directives and (4) insert the new ones. In[4]:= dirs = Hue[__] | RGBColor[__] | Dashing[_] | GrayLevel[_] | Thickness[_] a pattern for the graphics directives (this are not all possible ones, perhaps you need to add something) (1) In[5]:= posx = Position[ip, dirs] Out[5]= {{1, 1, 2, 1, 1, 1}, {1, 1, 2, 1, 1, 2}, {1, 1, 2, 1, 1, 3}, {1, 1, 2, 1, 2, 1}, {1, 1, 2, 1, 2, 2}, {1, 1, 2, 1, 2, 3}, {1, 1, 3, 1, 1, 1}, {1, 1, 3, 1, 1, 2}, {1, 1, 3, 1, 1, 3}, {1, 1, 3, 1, 2, 1}, {1, 1, 3, 1, 2, 2}, {1, 1, 3, 1, 2, 3}, {1, 2, 2, 1, 1, 1}, {1, 2, 2, 1, 2, 1}, {1, 2, 3, 1, 1, 1}, {1, 2, 3, 1, 2, 1}} (2) We can easily recognize the different parts, for different lines (3) In[6]:= ipnew = Delete[ip, posx] What have we done? In[7]:= Show[ipnew] The graphis is intact, however colors are gone. Now do (4) Identifying the new positions to operate on: In[8]:= pos1 = Cases[posx, {1, 1, __, 1}] Out[8]= {{1, 1, 2, 1, 1, 1}, {1, 1, 2, 1, 2, 1}, {1, 1, 3, 1, 1, 1}, {1, 1, 3, 1, 2, 1}} In[9]:= pos2 = Cases[posx, {1, 2, __, 1}] Out[9]= {{1, 2, 2, 1, 1, 1}, {1, 2, 2, 1, 2, 1}, {1, 2, 3, 1, 1, 1}, {1, 2, 3, 1, 2, 1}} In[10]:= ipnew = Insert[ipnew, Hue[0], pos1] In[11]:= ipnew = Insert[ipnew, Unevaluated[Sequence[Hue[1/3, 1, .5], Dashing[{.03}]]], pos2] See, how a sequence of directive is inserted. In[12]:= Show[ipnew] -- Hartmut Wolf