TransWikia.com

Using nodes in tikz package hobby

TeX - LaTeX Asked by G. Fougeron on April 9, 2021

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}

One Answer

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

Correct answer by Zarko on April 9, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP