RE: Combining plots and using different colors
- To: mathgroup at smc.vnet.net
- Subject: [mg42702] RE: [mg42695] Combining plots and using different colors
- From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
- Date: Tue, 22 Jul 2003 04:40:39 -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: Monday, July 21, 2003 11:15 AM >To: mathgroup at smc.vnet.net >Subject: [mg42702] [mg42695] Combining plots and using different colors > > >I would greatly appreciate if someone could help me with the following >problem. > > > >I wrote the following simple code. > > > >pl1=Plot3D[2x+y^2, {x,-10,10}, {y,-10,10}]; > >pl2=Plot3D[x+y, {x,-10,10}, {y,-10,10}, ColorOutput -> CMYKColor]; > >Show[pl1, pl2] > > > >I tried many different things to have the two graphs in two >different colors >when they are plotted together but nothing seems to work. Is >it possible to >combine two three dimensional graphs in the same plot in >Mathematica and >color them differently? > > > Vladimira, there are several possibilities (not the ColorOutput option), to propose two of them: (1) paint the surfaces at full color (for full color contrast, but loose color shading then), (2) give the surfaces a SurfaceColor (more pleasing appearance, but less contrast). (1) with Plot3D: In[5]:= pl1x = Plot3D[{2x + y^2, Hue[1/3, .5, 1]}, {x, -10, 10}, {y, -10, 10}] Out[5]= \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator] In[6]:= pl2x = Plot3D[{x + y, Hue[0]}, {x, -10, 10}, {y, -10, 10}] Out[6]= \[SkeletonIndicator]SurfaceGraphics\[SkeletonIndicator] In[7]:= Show[pl1x, pl2x] Out[7]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[8]:= Options[%, Lighting] Out[8]= {Lighting -> False, Lighting -> True} Before combining with Show the SurfaceGraphics object from Plot3D are converted to Graphics3D objects, Lighting is turned off automatically (Lighting has a different meaning for SurfaceGraphics.) With ParametricPlot3D: We have to explicitely turn off the Lighting: In[9]:= pp1 = ParametricPlot3D[{x, y, 2x + y^2, Hue[1/3, .5, 1]}, {x, -10, 10}, {y, -10, 10}, BoxRatios -> {1, 1, .4}, Lighting -> False] Out[9]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[10]:= pp2 = ParametricPlot3D[{x, y, x + y, Hue[0]}, {x, -10, 10}, {y, -10, 10}, BoxRatios -> {1, 1, .4}, Lighting -> False] Out[10]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[11]:= Show[pp1, pp2] Out[11]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] (2) SurfaceColor is not possible with a SurfaceGraphics, such not for Plot3D, but ParametricPlot3D In[17]:= pps1 = ParametricPlot3D[{x, y, 2x + y^2, SurfaceColor[RGBColor[.5, 1, 1]]}, {x, -10, 10}, {y, -10, 10}, BoxRatios -> {1, 1, .4}] Out[17]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[23]:= pps2 = ParametricPlot3D[{x, y, x + y, SurfaceColor[RGBColor[1, .5, .5]]}, {x, -10, 10}, {y, -10, 10}, BoxRatios -> {1, 1, .4}] Out[23]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[19]:= Show[pps1, pps2] Out[19]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] We can however introduce SurfaceColor to the converted Graphics3D objects (fome the SurfaceColor objects), from your plots: In[12]:= g1 = Graphics3D[pl1] Out[12]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[13]:= g1s = Insert[g1, SurfaceColor[RGBColor[.5, 1, 1]], {1, 1}] Out[13]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[14]:= g2 = Graphics3D[pl2] Out[14]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[15]:= g2s = Insert[g2, SurfaceColor[RGBColor[1, .5, .5]], {1, 1}] Out[15]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] In[16]:= Show[g1s, g2s] Out[16]= \[SkeletonIndicator]Graphics3D\[SkeletonIndicator] N.B.: You cannot see what you have got, if you always put ";" at the end of your input line. I never do, except when I have got reason to do so, i.e. I expect output too huge. -- Hartmut Wolf