2
$\begingroup$

I'm trying to draw a family of ellipses with pre-defined foci as follows:

    foci = {{-3, 25}, {2, 20}};
    ContourPlot[Tr[EuclideanDistance[#, {x, y}] & /@ foci], {x, -5, 5}, {y, 10, 30},
      Epilog -> {Black, PointSize[Large], Point@foci}]

which produces the following output:

ellipses seem skew

The contours do seem to be ellipses, but not ones with the specified foci, and they also look like their axes are rotated at varying angles. How can I get ellipses with the correct foci?

$\endgroup$
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$ – bbgodfrey Mar 4 '15 at 23:11
4
$\begingroup$

Looks fine to me, once you get your aspect ratio proper.

foci = {{-3, 25}, {2, 20}};
ContourPlot[
 Total[EuclideanDistance[#, {x, y}] & /@ foci],
 {x, -5, 5}, {y, 10, 30},
 AspectRatio -> 2,
 Epilog -> {Black, PointSize[Large], Point@foci}]

enter image description here

or your horizontal and vertical ranges equal:

foci = {{-3, 25}, {2, 20}};
mycontplot = ContourPlot[
  Total[EuclideanDistance[#, {x, y}] & /@ foci],
  {x, -10, 10}, {y, 10, 30},
  Epilog -> {Black, PointSize[Large], Point@foci}]

enter image description here

$\endgroup$
  • $\begingroup$ +1, AspectRatio->Automatic will work in general. $\endgroup$ – Kuba Mar 4 '15 at 23:20

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.