0

I would like to pin from the perimeter an ellipse built with a command \draw by specifying a particular point (like south, north west, etc) or an angle for example, as is possible with a node. The best I have been able to do so far with my various attempts is to pin the center of the ellipse, but not its perimeter.

I have looked for a solution but have not found one. I tried to name the ellipse via the name path option, but it does not work. I have the following error message : Package pgf Error: No shape named '...' is known..

So, how can I pin an ellipse to get a result like this?

enter image description here

In general, is it possible to convert simple shapes such as rectangles, circles and ellipses drawn with the \draw command to shape in the Tikz sense?

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections}

\begin{document}
\begin{tikzpicture}
    \draw [rotate around={-45:(0.8,0.4)}, name path=test](0.8,0.4) ellipse [x radius=2.5mm , y radius= 5.5mm];%
    \node[pin = {[]45:Test}] at (test.south) {};
\end{tikzpicture}
\end{document}
1

2 Answers 2

5

You can use an ellipse node

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric, intersections}

\begin{document}
\begin{tikzpicture}
    \node[ellipse, draw, minimum width=5mm, minimum height=11mm, rotate around={-45:(0.8,0.4)}, pin=north:Test] {};
\end{tikzpicture}
\end{document}

enter image description here

3

There are surely more elaborate ways to do this, but you can add nodes (or other stuff) as markings to any path:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}

\begin{document}
\begin{tikzpicture}[decoration={
    markings,
    mark=at position .25 with {
        \node[pin={[]45:Test}, inner sep=0pt] at (0,0) {};
    }
    }]

    \draw[postaction={decorate}, rotate around={-45:(0.8,0.4)}] (0.8,0.4) 
        ellipse[x radius=2.5mm, y radius=5.5mm];
        
    \draw[postaction={decorate}] (0,-2) .. controls (1,0) and  (2,-3) .. (4,-2);
\end{tikzpicture}
\end{document}

enter image description here

Basic geometic forms such as rectangle, circle or ellipse are already available as shapes for nodes, the more elaborate ones via the shapes.geometric library. For such shapes, it would be better to use a node with a pin.

2
  • With this solution pin no longer work as expected, it does't rotate around the ellipse if you ought to change the angle.
    – antshar
    Jul 7, 2022 at 8:48
  • This is true. You would need to adjust both the position on the path and the angle of the pin. I added this suggestion, because the OP asked for a general solution to convert paths to nodes, so I though adding a solution that works for whatever path would be nice. But sure, If you just want to add a pin to a node shaped like an ellipsis, this is not quite the way to go. Jul 7, 2022 at 13:11

You must log in to answer this question.

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