# Order of domain interval plots differently on Contour [closed]

h = 2; k = 8; p = 10;
g1 = ContourPlot[{(x - h)^1.27 + (y - k)^3.75 == 1}, {x, 0, p}, {y, 0,
p}, ContourStyle -> Red];
g2 = ContourPlot[{(x - h)^1.27 + (y - k)^3.75 == 1}, {y, 0, p}, {x, 0,
p}, ContourStyle -> Blue] ;
g3 = Plot3D[{(x - h)^1.27 + (y - k)^3.75}, {x, 0, p}, {y, 0, p},
PlotStyle -> Red];
g4 = Plot3D[{(x - h)^1.27 + (y - k)^3.75}, {y, 0, p}, {x, 0, p},
PlotStyle -> Blue] ;
Show[{g1, g2}]
Show[{g3, g4}]


Same function but order of domain interval interchangeably mentioning seems to result in a different (inverse) function..

EDIT1:

Actually the import of my question is for generalization: $$(x-y)$$ domain interval plot order reversal supplies a means to visualize 2D/3D Contour and Monge inverse function plots .. Is it correct?

## closed as off-topic by Bob Hanlon, m_goldberg, Alex Trounev, MarcoB, bbgodfreyMay 24 at 0:05

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, m_goldberg, Alex Trounev, MarcoB, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

• This is the expected behaviour. You've switched the x and y axes, so the blue line should be a reflection of the red line about the line y = x. Whatever variable comes first is plotted along the x-axis in the contour plot, and the second variable is plotted along the y-axis. – MassDefect May 17 at 6:32
• In Plot3D also it is expected to be same function but differently depicted? – Narasimham May 17 at 6:51
• Yes, Plot3D will also do the same. Try Show[Plot3D[Exp[a] Sin[b], {a, 0, 5}, {b, 0, 5}], Plot3D[Exp[a] Sin[b], {b, 0, 5}, {a, 0, 5}]] and you'll see that there is a seam where the two plots are reflected about the line a = b. – MassDefect May 17 at 19:11

## 1 Answer

It's normal for Mathematica to take the first variable as the "x" axis, and the second variable as they "y" axis for for DensityPlot, ContourPlot, Plot3D, and possibly others as well. We don't technically have to label the variables as "x" and "y", we could just as easily use "a" and "b", so MMA just takes them in the order we specify them.

Switching the order of the variables will result in the function being mirrored across the line y = x (or a = b or whatever variables we're using).

This is most easily seen with Plot3D:

Show[
Plot3D[
Exp[a] Sin[b],
{a, 0, 5},
{b, 0, 5}
],
Plot3D[
{None, Exp[a] Sin[b]},
{b, 0, 5},
{a, 0, 5}
]
] • Actually the import of my question is for generalization: domain interval plot order reversal supplies a means to visualize 2D/3D Contour and Monge inverse function plots .. Is it correct? – Narasimham May 18 at 7:33
• @Narasimham I'm not sure what a Monge inverse function is, but in general I would say you can plot the inverse with this method. Of course, you can also do something like ContourPlot[Evaluate[y == x^2 /. {x -> y, y -> x}], {x, 0, 5}, {y, 0, 5} ] and switch x and y directly. They amount to the same thing as switching the domains. – MassDefect May 20 at 3:26
• Monge form is z= f(x,y) now stands apart from z= f(y,x) as you pictured above. – Narasimham May 20 at 9:25