How to draw an ellipse with controllable parameters?

The formula for ellipse is (x^2)/(a^2) + (y^2)/(b^2) = 1. Parameters a and b are called semi-major and semi-minor axis, respectively. In other words, 2a is the width whereas 2b is the height of an ellipse.

  • the main trick will be to parametrize the ellipse: x(t)=a*cos(t) and y(t)=b*sin(t) where 0\leq t\leq 2\pi; I don't know about feynmf, but this would be very easy in pgfplots or PSTricks; let me know if you'd like to see such a solution – cmhughes Dec 3 '12 at 17:29
  • Definitely, I'd like to see such a solution. Not only will it be helpful in and of itself, but also will give us an idea how to implement the code into FeynMP. Thank you. – Laura Dec 3 '12 at 20:44

You can also use tikz directly, without parametrizations: the circle construction lets you specify the desired values as x radius and y radius; a little example:




\draw[step=.5cm,gray!20,very thin] (-4,-5) grid (7,5);
\draw (-4,0) -- (7,0) coordinate (x axis);
\draw (0,-5) -- (0,5) coordinate (y axis);

\draw[red] (0,0) circle [x radius=\faxis,y radius=\saxis];
\draw[blue] (0,0) circle [x radius=\faxis,y radius=\saxis];
\draw[green] (2,0) circle [x radius=\faxis,y radius=\saxis,rotate=30];


enter image description here

  • Right, this is analogous to the MetaPost code of Ellipse(expr a, b) where x -> a, and y -> b. – Mafra Dec 3 '12 at 23:03

If you parametrize the ellipse as, for example,


where 0\leq t\leq 2\pi, then you can use pgfplots to plot it



% global settings int he preamble
\pgfplotsset{every axis/.append style={%
                                axis x line=middle,
                                axis y line=middle,
                            axis line style={<->}, % arrows on the axis
                            xlabel={$x$},          % default put x on x-axis
                            ylabel={$y$},          % default put y on y-axis

% change the arrows to stealth fighters (personal preference)                    

         xmin=-5, xmax=5, 
         ymin=-5, ymax=5,


A whole host of options are available to you- have a look at the manual and the other questions on this site tagged with pgfplots for examples :)

Following the comments, you could define a and b as follows

         xmin=-5, xmax=5, 
         ymin=-5, ymax=5,
  • Thank you so much cmhughes! Is it possible to have a and b defined somewhere to yield a full control? – Laura Dec 3 '12 at 21:09
  • @Laura you're welcome :) see the update – cmhughes Dec 3 '12 at 22:31

How exactly do you want to use this ellipse?

In any case, you can modify the FeynMF sources in a similar way as in How to draw oval with FeynMP? (or use the mechanism pointed out by egreg in his comments).

Since FeynMF uses Metapost in the background you need to know how to obtain the ellipse first. Simply scale the circle with the parameters a and b (the code below can be compiled with mpost file.mp and it produces an EPS file.1)


        def Ellipse(expr a, b) =
        draw fullcircle scaled 1cm xscaled a yscaled b


The rescaled circle is mathematically equivalent to an ellipse.

EDIT: Using egreg's suggestion I defined an elliptical blob from within the latex file using \fmfcmd


\def\fmfblobEllipse#1#2#3{\fmfcmd{vblobEllipse ((#1), (#2), \fmfpfx{#3});}}

    \fmfcmd{input vblobEllipse}

The file vblobEllipse.mp:

vardef vblobEllipse (expr bd, a) (text vl)=
  forsuffixes $=vl:
    if not vexists $: venter $; fi
    vlist[vlookup $]decor.shape := fullcircle xscaled a;
    vlist[vlookup $]decor.size := bd;
    vlist[vlookup $]decor.sty := "shaded";

Where I defined only one parameter for the ellipse, since the overall scale does not matter for the shape.

This is the diagram one gets from the above:

enter image description here

However if you need to use ellipses together with Feynman diagrams (in the sense of side-by-side, and not as being part of the diagram itself), you can generate one ellipse using mpost with the original code from above.

  • the idea of x or y-scaling of a circle isn't sufficient for my purpose. I need exact ellipse with controllable parameters within the picture environment. Isn't there a way in FeynMF [or FeynMP] to draw any given function with a \fmfcmd? – Laura Dec 3 '12 at 20:42
  • @Laura: Can you provide a MWE of what you want to do? Where do you want this ellipse to appear and why are you doing this from FeynMF instead of using MetaPost directly like above? I ask this because with the usual conventions for Feynman diagrams you never need to bother about ellipses at all... – Mafra Dec 3 '12 at 20:50
  • Mafra, unfortunately I don't have MWE. I need an ellipse to use it along with other Feynman graphs; maybe together injunction, for various presentations. Also, I am very interested to see how one can draw a random function with \fmfcmd albeit by abusing the FeynMF :) – Laura Dec 3 '12 at 21:09
  • Mafra, you said "The rescaled circle is mathematically equivalent to an ellipsis." Can you prove this claim? :) – Laura Dec 3 '12 at 23:24
  • @Laura: I can prove that, but others have already written about it before: math.stackexchange.com/questions/79842/… – Mafra Dec 3 '12 at 23:30

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.