30

Is anybody aware of a simple way to place nodes at arbitrary positions along an ellipse? Ideally I would want to mimic notation like

\draw (0,0) ellipse [ x radius=2, y radius = 1] node[pos=.3] {Hi, I am a node.};

But this does not work. It is possible to splice together four curves that will do a good approximation, for instance

\node[coordinate,name=top] at (0,3) {};
\node[coordinate,name=bottom] at (0,-3) {};
\node[coordinate,name=left] at (-5,0) {};
\node[coordinate,name=right] at (5,0) {};

\draw (left) .. controls ($(left)+(0,2)$) and ($(top)-(2,0)$) .. (top);
\draw (left) .. controls ($(left)-(0,2)$) and ($(bottom)-(2,0)$) .. (bottom);
\draw (right) .. controls ($(right)+(0,2)$) and ($(top)+(2,0)$) .. (top);
\draw (right) .. controls ($(right)-(0,2)$) and ($(bottom)+(2,0)$) .. (bottom);

will give a decent approximation to

\draw (0,0) ellipse [ x radius=5, y radius = 3];

Using this method I can then use the notation I wanted to use. But if I want to make several pictures with this method or make adjustments, then it can become a lot of work. Also, the control points I picked were from guess and check as opposed to some other knowledge (this is a fault I know) so for varying sizes I will need to guess and check each time. So I am hoping for something a little more compact.

1
  • With the arc operation (Section 13.8 of the version 2.00 TikZ manual) you can easily draw parts of an ellipse.
    – Caramdir
    Aug 16, 2010 at 8:00

3 Answers 3

40

You can let TikZ calculate the position of the node for you:

\usetikzlibrary{calc}

\begin{tikzpicture}
    \draw (2,0) ellipse (2 and 1);
    \node at ($(2,0)+(75:2 and 1)$) {a node};
\end{tikzpicture}

The key here is that (75:2 and 1) is the position at 75 degrees on an ellipse with axis lengths 2 and 1 centered at (0,0). The (2,0) is just an example how you get an off-center position.

1
  • Awesome. I did not realize that you could put an ellipse inside of the angular coordinates. This fits perfectly for what I was thinking.
    – TheAxeR
    Aug 17, 2010 at 15:01
12

One thing you could do is create an elliptical node and then use the anchor points of that node. So for example,

\node[draw,ellipse,minimum height=2cm,minimum width=4cm] (a) at (0,0) {};
\node[above right] at (a.75) {Hi I am a node};

Here 75 is the angle around the ellipse where you want the text node to be placed.

7

With pgf 2.10 CVS !! You need to use arc operation because you need to know the path wih a point for the beginning and a point final. Idem for the circle.

\documentclass[11pt]{scrartcl}
\usepackage{tikz}
\usetikzlibrary{%
  arrows,
  calc
}

\begin{document}
\begin{tikzpicture}

 \draw (8,0) arc [start angle=0,   
                  end angle=360,
                  x radius=2cm, 
                  y radius=4mm]
                                node [pos=0] {WITH} 
                                node [pos=.25] {CVS !!} 
                                node [pos=.5] {2.10}  
                                node [pos=.75] {PGF};

\end{tikzpicture}
\end{document}  

enter image description here

3
  • I don't know if it is ever needed but adding -- cycle might be an option just to be on the safe side.
    – percusse
    May 3, 2012 at 8:01
  • @percusse I don't know too but it's better to use it. May 3, 2012 at 8:47
  • Is it possible to do the same thing but with a rotated ellipse? The attribute rotate=45 does not work on arcs...
    – tobiasBora
    Feb 6, 2018 at 23:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .