I have a function thats domain is defined for x and y values and for x^2+y^2>=1. I can only manage to plot it with the Plot3D command, but I want a regular 2D graph. I've tried defining it multiple different ways to get it to plot in 2D, but to no avail. Here is what I have done:

f[x_, y_] := 
x + (x/((x^2) + (y^2))) /; -2 <= x <= 2 && 0 <= y <= 2 && 
x^2 + y^2 >= 1;

When I try to plot this with the regular Plot[] command I get errors. Here is how I have graphed it in 3D, but 3D is not beneficial to me, I need it in 2D.

Plot3D[f[x, y] && x^2 + y^2 >= 1, {x, -2, 2}, {y, 0, 2}, 
PlotPoints -> 100, Mesh -> None];


Plot3D[ConditionalExpression[x + x/(x^2 + y^2), x^2 + y >= 1], {x, -2,
2}, {y, 0, 2}]

Are you looking for something like a DensityPlot or ContourPlot?

I've redefined your f[x_, y_] as it wasn't necessary to include all the extra conditions if you're only going to plot in a certain region anyways.

f[x_, y_] := x + x/(x^2 + y^2) /; x^2 + y^2 >= 1
DensityPlot[f[x, y], {x, -2, 2}, {y, 0, 2}, PlotLegends -> Automatic]
ContourPlot[f[x, y], {x, -2, 2}, {y, 0, 2}, PlotLegends -> Automatic]

Density plot of poster's function.

Contour plot of poster's function.

In these plots, colour represents the value of f[x, y] along the axes x and y. Of course you can use any colour scheme you desire, or even make it all a single colour if you like.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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