Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

is there any way to plot a "3D set" of points subject to certain rules? For example, my task is to find maximum of some function of three variables which have to meet some conditions. Of course I can't use Plot3D and RegionFunction because I would need a 4D space. So I tried to plot only the constraints (where "z" would be a function of "x" and "y"): the constraints are 3x^2>2y^2+z^2 and x^2+y^2=1, and then I used

Plot3D[{Sqrt[3 x^2 - 2 y^2],-Sqrt[3 x^2 - 2 y^2]}, {x, -5, 5}, {y, -5, 5}, 
 RegionFunction -> Function[{x, y}, x^2 + y^2 <= 1 && x^2 + y^2 >= 1]]

But this isn't working for some reason - I get only a box without any plot, but even if it did work, it wouldn't be very helpful because the first contraint is inequality and not an equation. I hope I expressed myself correctly and comprehensibly, English is not my mother tongue. Any ideas how to solve my issue?

share|improve this question
Very generically, there is a RegioPlot3D function and you might be better off with a different parametrization (like polar) of your variables. – b.gatessucks May 22 '13 at 13:11
So I tried RegionPlot3D which I think would be an excellent way to plot what I need (I didn't know this function before). At first, when I used the given constraints, I did not get any result (only an empty box again) but then I tried to change the second constraint to inequality (x^2+y^2<=1) and everything worked fine. So I think the only problem is that RegionPlot3D is not able to deal with an equation in its argument. Thanks for help anyway! – Skumin May 22 '13 at 13:58

I guess you're trying to plot the set of points $(x,y,z)$ such that $3x^2>2y^2+z^2$ and $x^2+y^2=1$. Now RegionPlot3D only works for inequalities, while ContourPlot3D only works for equations. But you can use ContourPlot3D on the equation and supply it the inequality as a RegionFunction.

ContourPlot3D[x^2 + y^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -2, 2}, 
 RegionFunction -> Function[{x, y, z}, 3 x^2 > 2 y^2 + z^2], 
 BoxRatios -> Automatic]

enter image description here

You can even colour the plot with another function of $(x,y,z)$...

f[x_, y_, z_] := Sin[x] Cos[y] Tan[z]
ContourPlot3D[x^2 + y^2 == 1, {x, -1, 1}, {y, -1, 1}, {z, -2, 2}, 
 RegionFunction -> Function[{x, y, z}, 3 x^2 > 2 y^2 + z^2], 
 BoxRatios -> Automatic, 
 ColorFunction -> 
  Function[{x, y, z}, ColorData["LakeColors"][f[x, y, z]/2 + 1/2]], 
 ColorFunctionScaling -> False]

enter image description here

share|improve this answer
Thank you, this is exactly what I needed! – Skumin May 23 '13 at 15:10

Perhaps ContourPlot3D is useful, with an expression for x, y, and z, plus added constraints?

ContourPlot3D[Sin[x] Cos[y] Tan[z], 
 {x, -Pi, Pi},
 {y, -Pi, Pi}, 
 {z, -Pi, Pi},
 RegionFunction -> Function[{x, y, z}, (x^2 > (2 y^2 + z^2 ))],
 AxesStyle -> White
 Background -> Black]

what the hell is this supposed to be

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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