0

How can I create a curve by providing the coordinates of points 1-4.

enter image description here

2

2 Answers 2

3

Does this work for you?

\documentclass{standalone}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}
\draw [gray]  (0,0) -- (1,1) -- (2,0.75) -- (3,2);
\draw [red] plot [smooth, tension=0.6] coordinates { (0,0) (1,1) (2,0.75) (3,2)};
\end{tikzpicture}
\end{document}

The tension parameter lets you specify how much curvature you want in your smoothed spline. The output of the above code should provide you with something like this: enter image description here

2

Your curve seems to be defined by the slopes at some critical points. The hobby library is a great tool to draw such curves, see e.g. here for a survey of options. You can then specify the in angle, out angle and slope via tangent.

\documentclass[tikz,border=3mm]{standalone}
\usetikzlibrary{hobby}
\begin{document}
\begin{tikzpicture}[tangent/.style={%
    in angle={(180+#1)},Hobby finish,
    designated Hobby path=next,out angle=#1},
    pics/vert/.style={code={\draw (0,-0.1) -- (0,0.1) node[above]{#1};}}]
\draw [thick,use Hobby shortcut] 
   ([out angle=45]0,0) pic{vert=1}  .. ([tangent=0]1.5,1) pic{vert=2}
    ..  ([tangent=0]3,-0.25) pic{vert=3} .. ([in angle=225]4.5,1) pic{vert=4};
\end{tikzpicture}
\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .