Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
    
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 '10 at 8:00
add comment

3 Answers

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.

share|improve this answer
    
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 '10 at 15:01
add comment

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.

share|improve this answer
add comment

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

share|improve this answer
    
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 '12 at 8:01
    
@percusse I don't know too but it's better to use it. –  Alain Matthes May 3 '12 at 8:47
add comment

Your Answer

 
discard

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.