Sometimes the LaTeX engine decides not to insert the figure exactly where we want, and we want it right there. Well [h] or [h!] were the options I have tried so far, but they do not work well all the time, however if the figure is inserted with [H] option, the engine will not decide differently, even if next page or other things would ruin the layout, so I suggest to use
\begin{figure}[H]
...
\end{figure}
For more info you might check
here.