I like to avoid fill=white
. While the rectangle
path operator does not “care” for nodes, the orthogonal path operators -|
and -|
do. With a to path
, a rectangle
path consisting of two -|
can be easily re-created. (As the rectangle
path operator does not work quite good with nodes along a path either, I left out \tikztonodes
in the definition of the to path
but it can get added easily, if needed.)
If you add outer sep=0pt
to the definition of the circ
style, the lines get drawn to the middle of the circular line and you can avoid easily the (hardly noticeable) connection problems as highlighted in Better fitting line to node in TiKZ. Another solution would be to use line cap=round
or line cap=rect
(line cap=butt
is the default).
Code
\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz}
\tikzset{rect/.style={to path={-| (\tikztotarget) -| (\tikztostart) (\tikztotarget)}}}
\begin{document}
\begin{tikzpicture}[scale=0.3,
circ/.style={shape=circle, inner sep=1pt, draw, node contents=}]
\draw node (c1) at (1, 2) [circ, label=below:{$(1,2)$}]
node (c2) at (13,13)[circ, label=above:{$(13,13)$}]
(c1) to[rect] (8,4) to[rect] (6,11) to[rect] (c2);
\end{tikzpicture}
\end{document}
\draw (1,2) circle (1.5pt);