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.

This example:

\documentclass{article}

\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}%
    \draw[help lines] (0,0) grid (1,1);

    \node [draw, circle] at (0,0) {};
    \node [draw, circle] at (1,1) {};

    \draw[->] (0,0) -- (1,1);
  \end{tikzpicture}
\end{document}

plots two circles. But the arrow starts in the one circle and ends in the other circle. What I need is: starting and ending on the radius of the two circles.

How is this possible? Best if it is done automatically/dynmically depending on the size of the circles.

share|improve this question
1  
In this example, you're not actually using PGFPlots, but only TikZ/PGF. PGFPlots is a plotting environment that uses TikZ/PGF (and loads it automatically). I've edited the tags accordingly. –  Jake Jan 8 '13 at 16:08
    
Ah, thanks for that. :) I always don't really know the difference between these two and which command comes from what package actually in the end. ;) –  Foo Bar Jan 8 '13 at 16:09
    
But what about drawing dotted lines, i.e. \draw[dotted] (c1) -- (c2) because then there is no automatism. Any idea? –  fab Oct 24 at 20:31

1 Answer 1

up vote 13 down vote accepted

Use named nodes. They do that automatically.

To name nodes, use either

  • the name=<name> key, or
  • the special syntax (<name>) (see example below)

Code

\documentclass{article}
\usepackage{tikz}
\begin{document}
  \begin{tikzpicture}%
    \draw[help lines] (0,0) grid (1,1);
    \node [draw, circle]          (c1) at (0,0) {};% special syntax
    \node [draw, circle, name=c2]      at (1,1) {};% name key
    \draw[->] (c1) -- (c2);
  \end{tikzpicture}
\end{document}

Output

enter image description here

share|improve this answer
    
Wow, thanks. Life can be so easy if you just know that something exists. :) Will accept this answer when the wait time is over. –  Foo Bar Jan 8 '13 at 16:07

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.