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

I'm new to Mathematica, and I'm finding it difficult to plot an ellipse. I tried using

Plot[(x/5)^2 + (y/3)^2 == 1, {x, -5, 5}, {y, -3, 3}]

but I'm getting some errors. Is there something wrong with the syntax? Or do I need to rewrite the equation and plot?

share|improve this question
"Plot generates a plot of f as a function of x from xmin to xmax". So you're using too many variables. – cormullion Feb 24 '13 at 16:05
Closely related: Coloring a shape according to a function – Artes Aug 26 '13 at 16:53

Even though Mr. Wizard's answer plus comments give the most generalizable answers, the closest to what the original question was doing is probably this:

Plot[y /. Solve[(x/5)^2 + (y/3)^2 == 1], {x, -5, 5}, 
 AspectRatio -> Automatic]

solve plot

The ability to plot two branches of a solution as a single curve is sometimes cited as one of the advantages of the fact that Plot doesn't automatically evaluate its arguments due to its HoldAll attribute (which in other situations causes confusion when you try to plot lists of functions in different colors). Here we want both branches of the square root to appear in the same plot style, and this is automatically recognized. If I had forced the Solve output to be evaluated too early, this plot wouldn't work.

share|improve this answer

Please see this reference: How To | Create Plots.

You need ContourPlot for that implicitly defined function.
You will also need AspectRatio -> Automatic if you want it to look like an ellipse and not a circle.

ContourPlot[(x/5)^2 + (y/3)^2 == 1, {x, -5, 5}, {y, -3, 3}, AspectRatio -> Automatic]

Mathematica graphics

If you merely want to display an ellipse use Graphics:

Graphics[Circle[{0, 0}, {5, 3}]]

Mathematica graphics

Notice that AspectRatio -> Automatic was not needed; it is the default for Graphics, whereas plot functions default to 1/GoldenRatio.

Jens showed a use of Plot (which I voted for) that illustrates styling two solutions to an equation the same. This is useful, but it is also inefficient as we call Solve again and again. Alternatives are manually specifying the PlotStyle:

sols = y /. Solve[(x/5)^2 + (y/3)^2 == 1, y];

Plot[sols, {x, -5, 5}, PlotStyle -> Blue, AspectRatio -> Automatic]

And using Sequence to group the elements as I described in Difference in Plot when using Evaluate vs when not using Evaluate:

Plot[Sequence @@ sols, {x, -5, 5}, AspectRatio -> Automatic]

enter image description here

share|improve this answer
Another way:ParametricPlot[{ 5 Cos[t], 3 Sin[t]}, {t, -Pi, Pi}, AspectRatio -> Automatic] – ssch Feb 24 '13 at 14:37
Perhaps this, too: RegionPlot[Abs[(x/5)^2 + (y/3)^2 - 1] < .1, {x, -6, 6}, {y, -4, 4}, AspectRatio -> Automatic, PlotPoints -> 80] – Jens Feb 24 '13 at 17:29
ParametricPlot[{2*Sin[x], Cos[x]}, {x, 0, 2*Pi}]

Mathematica graphics

share|improve this answer

Use RegionPlot[] (for 2D shapes) or ContourPlot[] (for 1D boundaries):

ContourPlot[(x/5)^2 + (y/3)^2 == 1, {x, -5, 5}, {y, -3, 3}]

enter image description here

share|improve this answer
You might want to set AspectRatio -> Automatic for this. – J. M. Mar 4 at 14:42
It seems to me that the ContourPlot approach was covered previously in Mr.Wizard's answer to this very question, which also included the necessary AspectRatio adjustment already suggested by @J.M. . Perhaps you could expand on your answer to differentiate the two; otherwise this seems a duplicate of his answer to me. – MarcoB Mar 4 at 15:06
ISTM the earlier answer had too many alternatives and elaborations listed. I didn't even see it mentioning ContourPlot the first times I scrolled through it. – fche Mar 8 at 20:26

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.