[Date Index]
[Thread Index]
[Author Index]
Re: Superimposing 3D plots with different colours
*To*: mathgroup at smc.vnet.net
*Subject*: [mg74534] Re: Superimposing 3D plots with different colours
*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
*Date*: Sat, 24 Mar 2007 05:23:26 -0500 (EST)
*Organization*: The Open University, Milton Keynes, UK
*References*: <eu1rnv$lag$1@smc.vnet.net>
Rui Carvalho wrote:
> Hello,
>
> I need to superimpose two 3D curves and to distinguish them I need to have each in different colours. The code below shows my attempt, but it fails as Show reverts to the colours of the first plot. This is just test code, not the real code I'm working with.
>
> I don't need a code trick to combine both plots inside Show.
>
> What I have is two SurfaceGraphics objects, s1 and s2, which have different colours and I want to combine these so that both surfaces can be distinguished by colour. How can this be done?
>
>
> s1 = Plot3D[Cos[x y], {x, -Pi, Pi}, {y, -Pi, Pi}];
> s2 = Plot3D[Sin[x y], {x, -Pi, Pi}, {y, -Pi,Pi}, ColorFunction -> (If[# < 0.5, GrayLevel[0.5], GrayLevel[0.8]] &)];
> Show[{s1, s2}];
>
> Thanks a lot!
> Rui
>
You must add a ColorFunction to the first graph too, otherwise the
default function (Automatic) is replaced by the function defined by the
second graph. For instance,
In[1]:=
s1 = Plot3D[Cos[x*y], {x, -Pi, Pi}, {y, -Pi, Pi},
ColorFunction -> (If[#1 < 0.5, Hue[0.5], Hue[0.8]] & )];
s2 = Plot3D[Sin[x*y], {x, -Pi, Pi}, {y, -Pi, Pi},
ColorFunction -> (If[#1 < 0.5, GrayLevel[0.5],
GrayLevel[0.8]] & )];
Show[{s1, s2}];
Regards,
Jean-Marc
Prev by Date:
** Re: Definite Integration in Mathematica**
Next by Date:
**Re: CoefficientList**
Previous by thread:
**Superimposing 3D plots with different colours**
Next by thread:
**Re: Superimposing 3D plots with different colours**
| |