RE: Colors
- To: mathgroup at smc.vnet.net
- Subject: [mg34997] RE: [mg34986] Colors
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Wed, 19 Jun 2002 05:52:29 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
> -----Original Message----- > Sent: Tuesday, June 18, 2002 8:48 AM > Subject: [mg34997] [mg34986] Colors > > > Hi,I have the function ReY to reflect a curve about the Y axe: > > In[4]:= ReY[f_, {x_, x1_, x2_}] := Module[{p, q}, > p = Plot[f, {x, x1, x2}, DisplayFunction -> Identity]; > q = p /. {u_, v_} -> {-u, v}; > Show[p, q, DisplayFunction -> $DisplayFunction]] > > For ReY[Sin[t],{t,0,4}], I get both functions in black. > > I would like to use Hue[] to paint the curves in different > colors, but after > tryng to put Hue[] everywhere I get nothing. > > Another question is: What I have to do to allow ReY to work > with more than > one function, I mean: ReY[{Sin[t], t^3, Cos[t], ...},{t, 0,4}]. > > Finally: How I can paint the axes in other color then black?. > > Regards.Juan > > > > _________________________________________________________________ > MSN Photos es la manera m=E1s sencilla de compartir e imprimir > sus fotos: > http://photos.msn.com/support/worldwide.aspx > > Juan, an easy solution would be to produce both graphics directly by Plot and then combine with Show: In[17]:= reflectY[f_, {x_, x1_, x2_}, (opts___)?OptionQ] := Module[{p, q, ff = f /. x -> -x}, p = Plot[f, {x, x1, x2}, PlotStyle -> (PlotStyleRight /. {opts} /. PlotStyleRight -> Automatic), DisplayFunction -> Identity]; q = Plot[Evaluate[ff], {x, -x1, -x2}, PlotStyle -> (PlotStyleLeft /. {opts} /. PlotStyleLeft -> Automatic), DisplayFunction -> Identity]; Show[p, q, DisplayFunction -> $DisplayFunction]] In[18]:= reflectY[Sin[t], {t, -0.5, 4}, PlotStyleLeft -> {Hue[2/3], Dashing[{0.01, 0.01}]}, PlotStyleRight -> Hue[0]] In[19]:= reflectY[{Sin[t], Sin[1.2*t], Sin[1.5*t], Sin[1.9*t]}, {t, -1.2, 4}, PlotStyleLeft -> {Hue[2/3, 1, 1], {Hue[2/3, 0.7, 1]}, Hue[2/3, 0.3, 1], Hue[2/3, 0.2, 1]}, PlotStyleRight -> {Hue[0, 1, 1], Hue[0, 0.7, 1], Hue[0, 0.3, 1], Hue[0, 0.2, 1]}] In[20]:= reflectY[{Sin[t],t^3,Cos[t]},{t,0,4}] This solution is simple and deals with style options in the way as used from Plot. Normally one would give reflectY the Options PlotStyleRight -> Automatic and PlotStyleLeft -> Automatic, but since we deal with no other options here, that might be frozen into the coding (as done above). See also that we have to Evaluate[ff]. However it is more difficult to manipulate all the Line graphics primintives to get them reflected with new directives. Here is an attempt: In[3]:= ReY[f_, {x_, x1_, x2_}, (opts___)?OptionQ] := Module[{p, q}, p = Plot[f, {x, x1, x2}, PlotStyle -> (PlotStyleRight /. {opts} /. PlotStyleRight -> Automatic), DisplayFunction -> Identity]; q = p /. {u_Real, v_Real} -> {-u, v} /. {s__, graphics_} /; MemberQ[graphics, Line[_]] :> Join[{s} /. Thread[(PlotStyleRight /. {opts}) -> (PlotStyleLeft /. {opts})], {graphics}]; Show[p, q, DisplayFunction -> $DisplayFunction]] In[4]:= ReY[{Sin[t], Sin[1.2*t], Sin[1.5*t], Sin[1.9*t]}, {t, -1.2, 4}, PlotStyleLeft -> {{Hue[2/3, 1, 1]}, {Hue[2/3, 0.7, 1]}, {Hue[2/3, 0.3, 1]}, {Hue[2/3, 0.2, 1]}}, PlotStyleRight -> {{Hue[0, 1, 1]}, {Hue[0, 0.7, 1]}, {Hue[0, 0.3, 1]}, {Hue[0, 0.2, 1]}}] In[5]:= ReY[Sin[t], {t, -0.5, 4}, PlotStyleLeft -> {{Hue[2/3], Dashing[{0.01, 0.01}]}}, PlotStyleRight -> {{Hue[0]}}] In[6]:= ReY[{Sin[t], t^3, Cos[t]}, {t, 0, 4}] Here, because we use Thread, the structures for PlotStyleLeft and PlotStyleRight must be the same (at Level 1). Best is to always wrap the directives for each line with List, even if there is only one. Also all directives PlotStyleRight must be different to replace them with the corresponding PlotStyleLeft directives. Also we rely on the order of the directives in the Graphics not to be changed from there specification. Certainly one can repair these defects, but it isn't worth it. For your final question please consult Help. -- Hartmut