Using the Hobby algorithm for smoothly connecting points
John Hobby, the creator of the MetaPost graphic language, developed an algorithm for drawing a curve through a given set of points. That’s similar to the previous section’s approach because it internally creates a list of cubic Bézier curves. The curves are parameterized in order to be joined together very smoothly. This provides very pleasing results. It’s not about perfect approximation; it’s about very smooth curves.
For us, it’s just another syntax with a different result. First, load the hobby
library:
\usetikzlibrary{hobby}
Now, we set up a plot with start and end coordinates and two intermediate coordinates. We will take a few coordinates we used for Figure 12.5 to get a comparable result. The main difference is that we use hobby
as a plot
option:
\draw plot[hobby] coordinates { (-3,-2.4) (-1.3,0.86) (1.3,-0.86) (3,2.4)};
Compile it, and you get a curve...