Formatting tikzpicture plots side by side/ how to use \begin{figure}[htdp] or \begin{figure}[h]

I'm new latex. I've been trying to learn how to format these plots side by side on one line, but I have not been able to successfully. I don't understand how to use the \begin{figure}[h] feature or the subfigure. Any help would be appreciated.

**\documentclass[a4paper,12pt,twoside]{book}
\usepackage{amsmath,bm, graphicx, pgfplots}
\usepackage{pgfplots}
\pgfplotsset{compat=1.7}
\usepackage{graphicx}
\graphicspath{ {Figure_1.png}, {logo.gif} }
\usepackage{amsmath}
\usepackage{nccmath}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[utf8]{inputenc}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{hyphenat}
\usepackage{graphicx}
\usepackage{subfigure}
\usepackage{subfig}
\usepackage{multirow}
\usepackage{array}
\usepackage{graphicx,subfigure}

\begin{document}
\begin{figure}[h]
\centering
\subfigure[Figure A]{\label{fig:a}
\begin{tikzpicture}[baseline=0pt]
\begin{axis}[
xmin=-2.5, xmax=2.5,
ymin=-1.5, ymax=1.5,
axis lines=center,
axis on top=true,
domain=-2.5:2.5,
ylabel=$y$,
xlabel=$x$,
]
\\
\node [right, red] at (axis cs: -1.1,1.1) {$y = 0.5 *(1 + \tanh x)$};

\draw [blue, dotted, thick] (axis cs:-2.5,0)-- (axis cs:2.5,0);
\draw [blue, dotted, thick] (axis cs:-2.5,+1)-- (axis cs:2.5,+1);
\end{axis}
\end{tikzpicture}
}
\subfigure[Figure B]{\label{fig:b}
\begin{tikzpicture}[
declare function={
func(\x)= (\x <= 0) * (0)   +
and(\x > 0 , \x < 1) * (\x)     +
(\x >= 1) * (1)
;
}
]
\begin{axis}[
xmin=-2.5, xmax=2.5,
ymin=-1.5, ymax=1.5,
axis lines=center,
axis on top=true,
domain=-2.5:2.5,
ylabel=$y$,
xlabel=$x$,
]

\end{axis}
\end{tikzpicture}
}
\subfigure[Figure B]{\label{fig:c}
\begin{tikzpicture}[
declare function={
gunc(\x)= (\x <= 0) * (0)   +
(\x > 0) * (\x)
;
}
]
\begin{axis}[
xmin=-2.5, xmax=2.5,
ymin=-1.5, ymax=1.5,
axis lines=center,
axis on top=true,
domain=-2.5:2.5,
ylabel=$y$,
xlabel=$x$,
]

\end{axis}
\end{tikzpicture}
\label{fig:image3}
}
\end{figure}
\begin{figure}
\centering
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}
\begin{axis}[
axis y line = middle,
axis x line = middle,
xlabel = $x$,
ylabel = {$f(x) = x^3$},
grid=major,
]
domain=-3:3,
samples=100,
color=red,
]
{x^3};
\addlegendentry{$x^3$}
%
domain=-3:3,
samples=100,
color=blue,
]
{x^3 + 3};
\addlegendentry{$x^3 + 3$}
%
domain=-3:3,
samples=100,
color=green,
]
{x^3 - 3};
\addlegendentry{$x^3 - 3$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
%\hfill
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}
\begin{axis}[
axis y line = middle,
axis x line = middle,
xlabel = $x$,
ylabel = {$f(x) = x^3$},
grid=major,
]
domain=-3:3,
samples=100,
color=red,
]
{x^3};
\addlegendentry{$x^3$}
\end{axis}
\end{tikzpicture}
\end{subfigure}
\caption{lajsdfls}
\end{figure}
\end{document}**

• I’m voting to close this question because it belongs to the main site. – CarLaTeX Jul 7 at 18:35

Your document example has many issues:

1. Each package load only once (for example, you load graphicx three times!).

2. Be aware, if any of loaded package is obsolete, for example subfigure is replaced by subfig, however the most powerful package for sub -figures and -tables is subcaption package.

3. For floats placement you should enable, that LaTeX can select optimal position in the document. For example, use only h not enable this, so it is good to add options t (top), or b (bottom) or p (page) or combination of all.

Many people, that they not "boring" with floats placement, in preamble add

\makeatletter
\def\fps@figure{hbtp}
\def\fps@table{hbtp}
\makeatother


and than don't write float placement (see MWE below).

4. Use, if possible, recent version of packages (they have new, improved features, removed discovered bugs, etc. For example, instead ancient pgfplots version 1.7 use recent version 1.18.

5. Make yourself familiar with used packages: read their documentations (well, some packages have huge documentation, but such usually contain tutorials for their use)

So, for your document I would use preamble with recent version of LaTeX and all packages as is in the following MWE (which base on my answer on one of yours previous question:

\documentclass[a4paper,12pt,twoside]{book}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}

\usepackage{amsmath,bm}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{graphicx}
\graphicspath{ {Figure_1.png}, {logo.gif} }
\usepackage{nccmath}    % it load amsmath too
\usepackage{array, multirow}

\usepackage{caption}
\usepackage{subcaption}
\makeatletter
\def\fps@figure{hbtp}
\def\fps@table{hbtp}
\makeatother

\usepackage{hyphenat}

\begin{document}
\begin{figure}
\centering
\pgfplotsset{
xmin=-2.5, xmax=2.5,
ymin=-1.5, ymax=1.5,
axis lines=center,
axis on top=true,
domain=-2.5:2.5,
ylabel=$y$,
xlabel=$x$,
}

\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[scale=0.6,]
\begin{axis}
\node [right, red] at (-1.1,1.1) {$y = 0.5 *(1 + \tanh x)$};
\draw [blue, dotted, thick] (-2.5,0) -- (2.5,0);
\draw [blue, dotted, thick] (-2.5,1) -- (2.5,1);
\end{axis}
\end{tikzpicture}
\caption{one}
\label{fig:a}
\end{subfigure}%
\hfill%
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[scale=0.6,
declare function={func(\x)= (\x <=0) * (0)  +
and(\x >0, \x < 1) * (\x) +
(\x >=1) * (1);}
]
\begin{axis}
\end{axis}
\end{tikzpicture}
\caption{two}
\label{fig:b}
\end{subfigure}%
\hfill%
\begin{subfigure}[b]{0.3\textwidth}
\begin{tikzpicture}[scale=0.6,
declare function={gunc(\x)= (\x <=0) * (0) +
(\x > 0) * (\x);}
]
\begin{axis}