Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This question already has an answer here:

I have a 3D Plot with 3 separate functions for z in terms of x and y. I would like to convert this to a RegionPlot with the max of the three functions plotted for the variables x and y.

Essentially, this would be the top view of the 3D Plot, as whatever function is visible from the top is the highest and thus the maximum at that point.

However, I also need to add a Manipulate to this so it cannot merely be an image of the top view of the 3D Plot.

 Manipulate[
 Plot3D[{0.1, 
     Piecewise[{{α - ((2 α - 1)  α)/y + (
         x*α^2)/(2 y ), (1 - α) + α^2/(2 y) >= 
         0.35}}], 
     Piecewise[{{α + (1 - α)^2/(
         2 y), (1 - α) + (((3 α - 
               1) - ((Abs[1 - x]) (1 - α))) (1 - α))/(
          2 y) >= 0.35}}], 
     Piecewise[{{α - ((2 α - 1) α)/((2 - 
            a) 2) + ((3 - 2 a - Abs[x - a] ) α^2)/(
         2 y*(2 - a)^2), (1 - α) + α^2/(2 y (2 - a)) >= 
         0.35}}]} /. {a -> ((1 + z)/2), x -> 1} // 
   Evaluate, {α, 0, 1}, {z, 0, 1}, 
   AxesLabel -> Automatic, 
  PlotRange -> Automatic, 
  PlotStyle -> {Black, Green, Orange, Blue}], {{y, 2, 
   Gamma}, 1, 5}]

I would like a 2D Plot from this top view

share|improve this question

marked as duplicate by Rahul, MarcoB, Yves Klett, Bob Hanlon, Michael E2 plotting Jan 5 at 3:30

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
Please add your function and code. – Alexei Boulbitch Jan 4 at 12:23
up vote 8 down vote accepted

Here are three example functions,

f1 = Exp[-x^2 - y^2];
f2 = .5 Sin[x - y];
f3 = .002 x^2 + .07 y^2;

And here is a top-down view of the 3D plot,

Plot3D[{f1, f2, f3}, {x, -6, 6}, {y, -4, 4}, PlotPoints -> 100, 
 ViewCenter -> {0.5, 0.5, 0.5}, ViewPoint -> {0, 0, 4}]

enter image description here

And here is the same view, using RegionPlot

RegionPlot[{
  f1 > f2 && f1 > f3,
  f2 > f1 && f2 > f3,
  f3 > f1 && f3 > f2},
 {x, -6, 6}, {y, -4, 4},
 BoundaryStyle -> Dashed]

enter image description here

Or, using your example,

Manipulate[
 Module[{flist, f1, f2, f3, f4},
   flist = {f1, f2, f3, f4} = 
       Evaluate[{0.1, 
             Piecewise[{{α - ((2 α - 1) α)/

            y + (x*α^2)/(2 y), (1 - α) + α^2/(2 \
y) >= 0.35}}], 

       Piecewise[{{α + (1 - α)^2/(2 y), (1 - α) + 
            (((3 α - 
                   1) - ((Abs[ 
                    1 - x]) (1 - α))) (1 - α))/(2 y) >= \

                     0.35}}], 

       Piecewise[{{α - ((2 α - 1) α)/((2 - 
                               a) 2) + ((3 - 2 a - 
                               Abs[x - a]) α^2)/(2 y*(2 - 

                 a)^2), (1 - α) + α^2/(2 y (2 - a)) >= 
                     0.35}}]} /. {a -> ((1 + z)/2), x -> 1}];
   RegionPlot[{
       f1 == Max@flist,
       f2 == Max@flist,
       f3 == Max@flist,
       f4 == Max@flist
       }, {α, 0, 1}, {z, 0, 1},
     BoundaryStyle -> None
     , PlotPoints -> 50, PlotStyle -> {Black, Green, Orange, Blue}]
  ]
  , {{y, 2, Gamma}, 1, 5}]

Using the PlotPoints option severely slows it down, but makes the plot smoother.

enter image description here

share|improve this answer

Here's my answer here applied to this question:

Manipulate[
 With[{fns = {0.1, 
      Piecewise[{{α - ((2 α - 1) α)/y + (x*α^2)/(2 y), (1 - α) + α^2/(2 y) >= 0.35}}], 
      Piecewise[{{α + (1 - α)^2/(2 y),
         (1 - α) + (((3 α - 1) - ((Abs[1 - x]) (1 - α))) (1 - α))/(2 y) >= 0.35}}], 
      Piecewise[{{α - ((2 α - 1) α)/
           ((2 - a) 2) + ((3 - 2 a - Abs[x - a]) α^2)/(2 y*(2 - a)^2),
         (1 - α) + α^2/(2 y (2 - a)) >= 0.35}}]} /. {a -> ((1 + z)/2), x -> 1}}, 
  ContourPlot[Ordering[fns, -1], {α, 0, 1}, {z, 0, 1}, 
   Contours -> 1/2 + Range[Length@fns - 1], 
   ContourShading -> {Black, Green, Orange, Blue}, 
   MaxRecursion -> ControlActive[1, 4]]
  ],
 {{y, 2, Gamma}, 1, 5}]

Mathematica graphics

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.