I want to create a Graph like this for my Document. I know how to create a Graph with pgfplots and tikz, but how would I create these arrows and their explanations iteration x

This is where it is from: https://towardsdatascience.com/machine-learning-fundamentals-via-linear-regression-41a5d11f5220

Graph from https://towardsdatascience.com/machine-learning-fundamentals-via-linear-regression-41a5d11f5220

  • Welcome to TeX-SX! As a new member, it is recommended to visit the Welcome and the Tour pages to be informed about our format and also to know about Minimal Example. Otherwise, more specifically about your question: the data or a MWE that looks like the graph without the arrow would be a starting point for someone to help you.
    – R. N
    Dec 23, 2020 at 12:21
  • Do you want someone to make that chart for you? A tip, learn, try and fail, before asking for help.
    – scd
    Dec 23, 2020 at 16:19
  • I tried to do so and the Graph itself is eas.. I just dont know how to create these arrows Dec 23, 2020 at 16:31
  • Then please post the code that you have so far (starting with \documentclass and ending with \end{document}). Whoever wants to help you, can copy your code and extend it. Just click on the edit button left below your question, paste your code, and format it as code (mark the code lines and click on the '{}' button of the edit windows).
    – gernot
    Dec 23, 2020 at 16:37

1 Answer 1


This is a start.

\begin{tikzpicture}[declare function={F(\x,\a,\b,\c)=\a*exp(-(\x-\b)*(\x-\b)/\c);
    f(\x)=5-F(\x,4.5,2.8,6);},bullet/.style={circle,fill=black,inner sep=1pt},
 \draw[stealth-stealth] (0,6) node[below left]{$f(x)$} |- (6,0) node[below left]{$x$};
 \draw plot[smooth,domain=0:5] (\x,{f(\x)});
 \foreach \X [count=\Y]
    in {0.2,0.5,0.9,1.2,1.8,2,2.2,2.6,2.8}
    {\draw (\X,-0.2) -- (\X,0.2);
      \path (\X,{f(\X)}) node[bullet] (b\Y){};
     \draw[very thin,gray,-{Latex[bend,length=2pt,width=2pt]}] (b\the\numexpr\Y-1) 
        to[bend left] (\X,{f(\X)}) node[bullet] (b\Y){};
 \draw[stealth-] (b1) -- ++ (60:1) node[above]{Start};
 \foreach \Y in {2,3}
 {\path (b\Y) to[bend left] node[above right]{Iteration \Y} (b\the\numexpr\Y+1);}    

enter image description here

  • 1
    Exactly what I needed! Thank you very much! Dec 23, 2020 at 17:32

You must log in to answer this question.

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