6

I am using the package hobby for the first time, and it seems to me that using named nodes instead of coordinates is not supported. In particular, why do the following MWEs produce two different pictures ?

\documentclass[tikz,border=10pt]{standalone}
\usepackage{tikz}
\usetikzlibrary{hobby}

\begin{document}

\begin{tikzpicture}
\draw[help lines] (0,0) grid[step=0.25] (1,1);
\draw
(0,0) to [curve through={
(0.15,0.35) .. 
(0.5,0.5)   .. 
(0.8,0.6) } ]  
(1,1);
\end{tikzpicture}

\begin{tikzpicture}

\node (n1) at (0,0) {};
\node (n2) at (0.15,0.35){};
\node (n3) at (0.5,0.5){};
\node (n4) at (0.8,0.6){};
\node (n5) at (1,1){};

\draw[help lines] (0,0) grid[step=0.25] (1,1);
\draw
(n1) to [curve through={
(n2) .. 
(n3)   .. 
(n4) } ]  
(n5);
\end{tikzpicture}
\end{document}
3
  • Sorry for the hideous formatting, I am very new in this forum ... Dec 26, 2017 at 12:11
  • If you select your code and then click {} button above it in the editing mode, it marks it as a code block. Alternatively you can leave 4 whitespace characters manually.
    – percusse
    Dec 26, 2017 at 12:23
  • The "nodes aren't coordinates" issue has caused quite a few questions on this site. percusse's explanation at tex.stackexchange.com/a/81854/86 is a good one to read in addition to Zarko's answer below. Dec 26, 2017 at 18:04

1 Answer 1

6

nodes are not coordinates! they have non zero size, so the lines between them is discontinued. as work around you have two possibilities:

  • for named coordinates use for example

\draw
(n1.center) to [curve through={
(n2.center) ..
(n3.center)   ..
(n4.center) } ]
(n5.center);
  • or define named coordinates as

\coordinate (n1) at (0,0); 
\coordinate (n2) at (0.15,0.35); 
\coordinate (n3) at (0.5,0.5); 
\coordinate (n4) at (0.8,0.6); 
\coordinate (n5) at (1,1);

in both cases you will get the same result:

enter image description here

3
  • Amazing ! Exactly what I was looking for. I will study your "nodes are not coordinates!" remark :-). Dec 26, 2017 at 13:27
  • @G.Fougeron Coordinates are nodes, though. So some nodes are coordinates. But default nodes are not coordinates.
    – cfr
    Dec 27, 2017 at 1:32
  • 1
    Nodes can have zero size. \node [shape=coordinate] {};.
    – cfr
    Dec 27, 2017 at 1:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.