I know that the TikZ Arrow Tip Library (arrows) defines a circle arrow [-o], however this circle is too large for me. Is there any way I can control the size of the circle on the end of line?
Asked
Active
Viewed 6,851 times
1 Answers
17
You can use the decorations.markings library to define a style (say, o) that takes an optional argument for changing the size:

\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\begin{document}
\tikzset{
o/.style={
shorten >=#1,
decoration={
markings,
mark={
at position 1
with {
\draw circle [radius=#1];
}
}
},
postaction=decorate
},
o/.default=2pt
}
\begin{tikzpicture}
\draw [o] (0,1) -- (4,3);
\draw [o=1pt] (1,1) -- (4,2);
\end{tikzpicture}
\end{document}
Jake
- 232,450
-
This is not exaclty the same as [-o]. In [-o] circle touches the end of the path, while [o] draws circle on the end of the path... I know that I have to add 2* befor #1 on line 3 of the definition, but I do not know how to calculate new position... – Pygmalion Oct 29 '12 at 19:07
-
You can use
shorten >=2*#1together with\draw circle [xshift=-#1,radius=#1];. The local coordinate system is rotated, so thatxshiftmoves the mark in the direction of the line. – Jake Oct 29 '12 at 19:31 -
Hello Jake. I don't find how to get the circles at both tips of the line. Please could you help ? – Stéphane Laurent Feb 10 '16 at 14:33
-
Sorry I get it now. Just add a new mark with position=0. Thanks! – Stéphane Laurent Feb 10 '16 at 14:46
-
\begin{tikzpicture} \def\radius{2pt} \draw (0,0) -- (1,0) node [circle,radius=\radius,draw,fill=white,inner sep=\radius] {}; \end{tikzpicture}– hpesoj626 Oct 26 '12 at 14:48pgflibraryarrows.code.tex? If you change there the line\pgfpathcircle{\pgfqpoint{4.5\pgfutil@tempdima}{0bp}}{4.5\pgfutil@tempdima}by other with a value less than 4.5 you will obtain what you want. – rafaeldf Oct 26 '12 at 15:24\tikzset{o=<options go here>}, similar to how one can change the arrows easily using\tikzset{>=stealth}for example – cmhughes Oct 26 '12 at 19:26arrow sizekey. I've posted a bounty to that effect at http://tex.stackexchange.com/questions/5461/is-it-possible-to-change-size-of-arrowhead-in-tikz-pgf – Jake Oct 26 '12 at 21:48