How do I plot this modified GeoGebra picture using LaTeX code?

Point X on ellipse with foci F1 and F2, major axis AB, minor axis CD, center S at (p, q) and a red closing curly brace

  • 7
    If you don't care too much about the quality of the code, export TikZ or PSTricks from GeoGebra. Apr 19, 2016 at 19:01
  • 8
    Your question leaves all the effort to our community, even typing the essentials of a TeX document such as \documentclass{}...\begin{document} etc. Please always post a minimal working example (MWE). Apr 19, 2016 at 20:04

4 Answers 4


While the other solution looks great as well, the code is needlessly complicated. This code is very minimal and allows for easy customization by defining the relevant parameters as macros.

\begin{tikzpicture}[dot/.style={draw,fill,circle,inner sep=1pt}]
  \def\a{4} % large half axis
  \def\b{3} % small half axis
  \def\angle{-45} % angle at which X is placed
  % Draw the ellipse
  \draw (0,0) ellipse ({\a} and {\b});
  % Draw the inner lines and labels
  \draw (-\a,0) coordinate[label={left:$A$}] (A)
    -- (\a,0) coordinate[label={right:$B$}] (B);
  \draw (0,-\b) coordinate[label={below:$D$}] (D)
    -- (0,\b) coordinate[label={above:$C$}] (C);
  \coordinate[label={below right:$S(p,q)$}] (O) at (0,0);
  % Nodes at the focal points
  \node[dot,label={below:$F_1$}] (F1) at ({-sqrt(\a*\a-\b*\b)},0) {};
  \node[dot,label={below:$F_2$}] (F2) at ({+sqrt(\a*\a-\b*\b)},0) {};
  % Node on the rim, connected to foci
  \node[dot,label={\angle:$X$}] (X) at (\angle:{\a} and {\b}) {};
  \draw (F1) -- (X) (X) -- (F2);
  % Brace
  \draw[decorate,decoration=brace,draw=red] (C) -- (O);

enter image description here

For example, we can easily create these nice animations (me, 2016)

enter image description here

enter image description here


Hope this example will help you



    \begin{tikzpicture}[help lines/.style={blue!30,very thin},scale=0.6]
    \draw [help lines] (-7, -6) grid (7, 6);
    \draw[color=blue,very thick] (0, 0) ellipse (5cm and 4cm);

    \foreach \x/\y in {0/0, 5/0, -5/0,0/4, 0/-4 , 4/-2.4}
    \filldraw[black] (\x, \y) circle(1.5pt);

    \foreach \x/\y in { -3/0, 3/0}
    \filldraw[blue] (\x, \y) circle(2pt);

    \draw[->] (-7, 0) -- (7, 0) node[below]{\footnotesize $x$};
    \draw[->] (0, -5) -- (0, 5) node[right]{\footnotesize $y$};
    \draw[-] (-3, 0) -- (4, -2.4); 
    \draw[-] (3, 0) -- (4, -2.4); 
    \draw [decorate,decoration={brace,amplitude=6pt},xshift=-0.2cm,yshift=0pt,red]
      (0,0) -- (0,4);
    \node at (.9,-0.6) {$S(p,q)$};
    \node at (-5.6,-0.5) {$A$};
\node at (5.6,-0.5) {$B$};
\node at (-.3,4.4) {$C$};
\node at (-.5,-4.4) {$D$};
    \node at (-3.3,0.6) {$F_1$};
    \node at (3.3,0.6) {$F_2$};
    \node at (5.2,-2.8) {$(x,y)$};

enter image description here

  • I've added the red brace, but after \usetikzlibrary{decorations.pathreplacing}
    – Olga K
    Apr 19, 2016 at 19:25
  • 1
    Did you know, that you can specify points on an ellipse by polar coordinates as in (45:5 and 4). This way you do not have to compute the points by hand. Apr 19, 2016 at 19:54
  • Thank you, I use polar or cartesian coordinates according my mood) Actually the example above is naive, I agee.
    – Olga K
    Apr 19, 2016 at 20:04
  • Strictly speaking, your red brace is on the wrong side of the y axis. You should flip it with the mirror optional argument, and then shift it slightly on the positive side by replacing xshift=-0.2 by xshift=0.1. See tex.stackexchange.com/a/20887/80509.
    – Matsmath
    May 5, 2016 at 9:22
  • Thank you, I see. Indeed such "wrong" brace is more suitable to keep balance of the picture.
    – Olga K
    May 5, 2016 at 9:46

Here's a Metapost + luamplib solution, showing an MP function to find the focus points of an arbitrary ellipse.

enter image description here

The ellipse is only rotated to show that it works with any ellipse...

vardef focus(expr e, n) = 
  save a, b; numeric a,b;
  a = arclength (point 0 of e .. center e);
  b = arclength (point 2 of e .. center e);
  ((a+-+b)/a)[center e, point if n=1: 4 else: 0 fi of e]

path E; E = fullcircle xscaled 8cm yscaled 5cm rotated 6;

draw point 0 of E -- point 4 of E withcolor .7 white;
draw point 2 of E -- point 6 of E withcolor .7 white;
draw E withcolor .67 blue;

z0 = point 6.812 of E;
z1 = focus(E,1);
z2 = focus(E,2);

draw z1 -- z0 -- z2 withcolor .53 red;

dotlabel.top("$f_1$", z1);
dotlabel.top("$f_2$", z2);
dotlabel.bot("$X$", z0);

label.lft("$A$", point 4 of E);
label.rt ("$B$", point 0 of E);
label.top("$C$", point 2 of E);
label.bot("$D$", point 6 of E);



  • On a fullcircle path there are 8 points starting at 3 o'clock.

  • center returns the center point of the bounding box of any path.

  • The function uses arclength to measure the semi-major axes of the ellipse, and then the Pythagorean minus operator +-+ to work out the length from the center to the focus.


A PSTricks solution:


\psset{dimen = m}

% parameters
\def\pointX{1.5} % |\pointX| < |\radiiA|
% shortened code
\ifdim \pointX pt < 0pt


% picture
 {\psset{linewidth = 0.5\pslinewidth}
    braceWidth = 1pt,
    braceWidthInner = \braceSize,
    braceWidthOuter = \braceSize,
    fillstyle = solid,
    fillcolor = \braceColor,
    linecolor = \braceColor



All you have to do is change the values of the parameters and the drawing will by adjusted accordingly.

  • 1
    The focal points F_1 and F_2 are positioned incorrectly. They should be at ±√5 in your example. Apr 19, 2016 at 21:57
  • @HenriMenke Thanks. Corrected and the missing things added. Apr 20, 2016 at 8:14

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.