# Tikz: Draw simple shortened curved line between two coordinates in tikz

I'm creating an overlay to a picture. The picture has several objects and I want to draw arrows between them. I only have the coordinates and not the sizes so I must offset the arrows as not to overlap the objects.

Here is the image to use. Try to create an arrow, similar to the yellow curved line, to the black circle from the green circle.

I would like to "shorten" the arrows by giving a length that it offsets from both ends. (so 0cm would start and stop the arrow at the endpoints and 0.1cm will start it 0.1cm and stop it at 0.1cm) I would also like to set a curvature amount like "0.4" that will curve the arrow some amount. (0 = straight, 1 = maximum curvature possible)

\begin{tikzpicture}
\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics{hnRDQ.png}};
\coordinate (G) at (2.3,6.1);
\coordinate (R) at (6.4,3.9);
\coordinate (B) at (2.1,1.7);
\draw [green] (G) -- (R);
\draw [red]   (R) -- (B);
\draw [black] (B) -- (G);
\end{tikzpicture}

(the coordinates are only approximate)

Clarify:

I want to basically specify the radius of curvature of the "arc". So, instead of having to specify the angle in and the angle out I want to specify one number. The in and out angles should be easily computed from the radius of curvature...

Basically I would like to do something like \draw (A) [arc=0.5] (B); And it draws a 3 point arc with the 3rd point being on the radius of curvature, the 0.5 specifying out far out.

• I don't get the question completely but are you looking for \draw [black,shorten <=1cm,shorten >=1cm] (B) -- (G);? Commented Nov 20, 2012 at 1:56
• Combine both answers and percusse's comment and you might see the difference between \draw (some node 1) -- (some node 2); and \draw (some coordinate 1) -- (some coordinate 2); where in the last example nodes are drawn at those coordinates. For your use case (what I can see from your picture) I recommend re-drawing those circles (as nodes). Commented Nov 20, 2012 at 3:12
• @Qrrbrbirlbel The picture is only an example, mine is much more complex and doesn't even have circles. What if it was a horse and a pig and you wanted to draw a line between one and the other? Commented Nov 20, 2012 at 3:17
• @JonSlaughter There is \draw (a) arc[radius=1cm, start angle=<alpha>, end angle=<beta>]; where <alpha> and <beta> are arbitrary angles (there's also delta angle). For a less manual way, I think tkz-euclidecan help here (especially the multi-functional \tkzDrawArc). Commented Nov 20, 2012 at 3:36
• For the to-path keys out and in does also exist the looseness key that kind of works like your arc=0.5 specification would (PGF/TikZ manual, section 51.3 “Curves”, pp. 469ff.). Commented Nov 20, 2012 at 3:47

I am also not 100% sure about the question, but hope this addresses the various parts I see.

Here is an example of a straight line, a curved line, and a shortened curved line (in violet):

## 1. Draw Straight Line:

\draw  (G) -- (R)

produces the straight olive line from (G) to (R).

## 2. Curved Line:

\draw    (R) to[out=-20,in=-70] (B)

produces the red line with curvature. Instead of using --, we use the to syntax, and the options out= specifies the angle at the start point, and the in= specifies the angle at the end point.

Using distance=3cm with the same in=, and out= we get the red dotted line.

## 3. Shortened Line:

Withe either of the straight or curved lines, one can use shorten <= to shorten the start point or shorten >= to shorten the end point. A shorten of 0.25cm is applied to both ends of the violet line.

## Code:

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[ultra thick]
\coordinate (G) at (2.3,6.1);
\coordinate (R) at (6.4,3.9);
\coordinate (B) at (2.1,1.7);

\node [fill=green,circle] at (G) {};
\node [fill=red,  circle] at (R) {};
\node [fill=blue, circle] at (B) {};

\draw [olive, -] (G) -- (R);
\draw [red]   (R) to[out=-20,in=-70] (B);
\draw [red,dotted]   (R) to[out=-20,in=-70, distance=3cm ] (B);
\draw [violet, ->, shorten <= 0.25cm, shorten >= 0.25cm] (B) to[out=120,in=150] (G);
\end{tikzpicture}
\end{document}
• Basically I want to use special values for in and out. Draw a 3 point arc with 2 points being the two coordinates/nodes. The 3rd point is a line midway in between the two points and tangent to the line connecting the nodes. The radius of curvature then specifies how curved the arc is. Commented Nov 20, 2012 at 3:19
• Sorry, but I am still not following. It would recommend that you illustrate what you describe with code. So, edit the question and include a manually crafted example of what you describe above. Make it clear what is provided, and what is being determined. You can for instance take my example, and replace all the \draw commands with something that shows your desired syntax (commented out as it won't work yet), and the code that that syntax should be equivalent to. Commented Nov 20, 2012 at 3:26

I don't also know if I am understanding your question right. But instead of specifying the amount of bend by length, you can specify it by angle as in my answer.

\documentclass[tikz,border=10]{standalone}

\begin{document}
\begin{tikzpicture}[line/.style={<->,shorten >=0.4cm,shorten <=0.4cm},thick]
%\node[anchor=south west,inner sep=0] at (0,0) {\includegraphics{hnRDQ.png}};
\node (G) [circle,draw,inner sep=0pt,minimum width=2cm]  at (2.3,6.1) {};
\node (R) [circle,draw,inner sep=0pt,minimum width=1.5cm] at (6.4,3.9) {};
\node (B) [circle,draw,inner sep=0pt,minimum width=1cm] at (2.1,1.7) {};
\path [green,line,bend left] (G) edge (R);
\path [red,bend left,line]   (R) edge (B);
\path [black,line,out=135,in=225] (B) edge (G); % you can control the bend by manually specifying in=<angle> and out=<angle> options
\end{tikzpicture}
\end{document}