Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to plot y = x^2 and x = y^2 on the some graph? For some reason, I can't get it to plot the x = y^2 properly. Here is what I get:

Show[{ Plot[x == y^2, {y, -1, 1}], Plot[y = x^2, {x, -1, 1}]}]

enter image description here

Thank you for your time.

share|improve this question
add comment

3 Answers 3

up vote 6 down vote accepted

Yes, you just have to change how you think about plotting, a little. Specifically, you are looking for ParametricPlot.

ParametricPlot[{{t, t^2}, {t^2, t}}, {t, -1, 1}]

Mathematica graphics

share|improve this answer
    
This is good to see. Thank you! –  spryno724 Nov 22 '12 at 5:26
    
Just wondering, is it possible to fill in the enclosed region? –  spryno724 Nov 22 '12 at 5:28
2  
@spryno724, that requires an entirely different approach... RegionPlot[x^2 < y && y^2 < x, {x, 0, 1}, {y, 0, 1}] –  J. M. Nov 22 '12 at 5:29
    
Ah... ok. Just thought I would check. –  spryno724 Nov 22 '12 at 5:30
add comment

rcollyer's method is the best way of going about it. Here's an alternative:

g = Plot[x^2, {x, -1, 1}];
Show[g, g /. v_ /; VectorQ[v, NumericQ] && Length[v] == 2 :> Reverse[v], 
     PlotRange -> All]

parabolas

Here's a more conventional route, tho:

ContourPlot[{y == x^2, x == y^2}, {x, -1, 1}, {y, -1, 1}, Axes -> True, Frame -> False]

parabolas, again

To see the filled version being asked in the comments:

Show[ContourPlot[{y == x^2, x == y^2}, {x, -1, 1}, {y, -1, 1}], 
     RegionPlot[x^2 < y && y^2 < x, {x, 0, 1}, {y, 0, 1}],
     Axes -> True, Frame -> False]

parabolas with filling

share|improve this answer
add comment

For completeness we can mention finding all branches of inverse function. It won't always work, but it is conceptually instructive for simple cases.

f[x_] = x^2; g[x_] = InverseFunction[f][x]

-Sqrt[x]

Plot[{f[x], g[x], -g[x]}, {x, -1, 1}, AspectRatio -> 1, Filling -> {1 -> {3}}]

enter image description here

share|improve this answer
1  
ParametricPlot needs Filling as an option! :) –  rcollyer Nov 22 '12 at 6:02
    
@rcollyer: orienting the filling would be a bit problematic, tho... –  J. M. Nov 22 '12 at 6:03
    
@rcollyer MeshShading as a remedy ;) –  Vitaliy Kaurov Nov 22 '12 at 6:04
    
@J.M. maybe. But, filling between lines would be less difficult. –  rcollyer Nov 22 '12 at 6:10
    
@VitaliyKaurov why yes it is, but I'll have to play with that tomorrow. –  rcollyer Nov 22 '12 at 6:10
add comment

Your Answer

 
discard

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.