% Modified from https://tex.stackexchange.com/a/261567.
\documentclass{standalone}
\usepackage[active,tightpage]{preview}
\usepackage{amsmath}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{arrows.meta,intersections,positioning}

\usepackage{anyfontsize}
\renewcommand{\normalsize}{\fontsize{14pt}{16pt}\selectfont}

\DeclareMathOperator{\dom}{dom}

\pgfmathdeclarefunction{func}{1}{%
  \pgfmathparse{max(19-4*(#1+8),19-3*(#1+8),7-1*(#1+4),2,2+1*(#1-3),3+2*(#1-4),7+3*(#1-6),19+4*(#1-10))}%
}

\pgfplotsset{compat=1.16}
\makeatletter
\pgfplotsset{
    mark max/.style={
        point meta rel=per plot,
        visualization depends on={x \as \xvalue},
        scatter/@pre marker code/.code={%
        \ifx\pgfplotspointmeta\pgfplots@metamax
            \def\markopts{mark=none}%
            \coordinate (maximum);
        \fi
            \def\markopts{mark=none}
            \expandafter\scope\expandafter[\markopts]
        },%
        scatter/@post marker code/.code={%
            \endscope
        },
        scatter
    }
}

% Syntax
% \DrawEpigraph[<additional options>]{<min domain x>}{<max domain x>}{<shift on the left>}{<shift on the right>}
\newcommand\DrawEpigraph[6][draw=white,top color=red!05,bottom color=red!45]{
  \coordinate (plot-left) at ([yshift=#4]axis cs:#2,\pgfplots@metamax);
  \coordinate (plot-right) at ([yshift=#5]axis cs:#3,\pgfplots@metamax);
  \path[name path=diagonal,draw=none] (plot-left) -- (plot-right);
  \addplot[#1] fill between[of=#6 and diagonal];
}
\makeatother

\PreviewEnvironment{tikzpicture}

\begin{document}    

\begin{tikzpicture}

\node (pic12) {
    \begin{tikzpicture}
        \node (pic1) {
            \begin{tikzpicture}
                \begin{axis}[
                axis lines=middle,
                xlabel={$x$},
                ylabel={$y$},
                xtick={\empty},
                ytick={\empty},
                x=1cm, y=1cm,
                ymin=0,
                ymax=5.5,
                xmin=-3,
                xmax=4,
                clip=false,
                axis on top,
                scale=1
                ] 
                % The Epigraph
                \draw [fill,draw=white,top color=red!05,bottom color=red!45] 
                    (axis cs:-2,5) -- (axis cs:0,1) -- (axis cs:1,1) 
                    -- (axis cs:2,2) -- (axis cs:3,4)
                    -- (axis cs:3,5.4) -- (axis cs:-2,5.4) -- cycle;
                % The curve
                \draw [red,very thick,name path=B]
                    (axis cs:-2,5) -- (axis cs:0,1) -- (axis cs:1,1) 
                        -- (axis cs:2,2) -- (axis cs:3,4);
                % Lines and labels
                \node[below] at (axis cs:0,0) {$O$};
                \node at (axis cs:1.7,2.7) {$f(x)$};
                \end{axis}
            \end{tikzpicture}
        };

        \node[right=0.1cm of pic1] (pic2) {        
            \begin{tikzpicture}
                \begin{axis}[
                axis lines=middle,
                xlabel={$x$},
                ylabel={$y$},
                xtick={\empty},
                ytick={\empty},
                x=1cm, y=1cm,
                ymin=0,
                ymax=5.5,
                xmin=-3,
                xmax=4,
                clip=false,
                axis on top,
                scale=1
                ] 
                % The Epigraph
                \draw [fill,draw=white,top color=blue!05,bottom color=blue!45] 
                    (axis cs:-1,1) -- (axis cs:0,0) -- (axis cs:2,2) 
                    -- (axis cs:2,5.4) -- (axis cs:-1,5.4) -- cycle;
                % The curve
                \draw [blue,very thick,name path=B]
                    (axis cs:-1,1) -- (axis cs:0,0) -- (axis cs:2,2);
                % Lines and labels
                \node[below] at (axis cs:0,0) {$O$};
                \node at (axis cs:0.2,1.6) {$g(x)$};
                \end{axis}
            \end{tikzpicture}
        };
    \end{tikzpicture}
};

\node[below=0.5cm of pic12] (pic3) {
    \begin{tikzpicture}
        \begin{axis}[
          axis lines=middle,
          xlabel={$x$},
          ylabel={$y$},
          xtick={\empty},
          ytick={\empty},
          x=1cm, y=1cm,
          ymin=0,
          ymax=7.5,
          xmin=-4,
          xmax=6,
          clip=false,
          axis on top,
          scale=1
        ] 
        % The Epigraph
        \draw [fill,draw=white,top color=violet!05,bottom color=violet!45] 
            (axis cs:-3,6) -- (axis cs:-1,2) -- (axis cs:0,1)
                -- (axis cs:1,1) -- (axis cs:4,4) -- (axis cs:5,6)
                -- (axis cs:5,7.4) -- (axis cs:-3,7.4) -- cycle;
        % The curve
        \draw [red,very thick,dashed]
            (axis cs:-2,5) -- (axis cs:0,1) -- (axis cs:1,1) 
                -- (axis cs:2,2) -- (axis cs:3,4);
        \draw [blue,very thick,dashed]
            (axis cs:-3,6) -- (axis cs:-2,5) -- (axis cs:0,7);
        \draw [blue,very thick,dashed]
            (axis cs:-1,2) -- (axis cs:0,1) -- (axis cs:2,3);
        \draw [blue,very thick,dashed]
            (axis cs:0,2) -- (axis cs:1,1) -- (axis cs:3,3);
        \draw [blue,very thick,dashed]
            (axis cs:1,3) -- (axis cs:2,2) -- (axis cs:4,4);
        \draw [blue,very thick,dashed]
            (axis cs:2,5) -- (axis cs:3,4) -- (axis cs:5,6);
        \draw [red,ultra thick,name path=B]
            (axis cs:-3,6) -- (axis cs:-1,2)
            (axis cs:0,1) -- (axis cs:1,1) -- (axis cs:2,2)
            (axis cs:4,4) -- (axis cs:5,6);
        \draw [blue,ultra thick,name path=C]
            (axis cs:-1,2) -- (axis cs:0,1)
            (axis cs:2,2) -- (axis cs:4,4);
        % Lines and labels
        \node[below] at (axis cs:0,0) {$O$};
        \node at (axis cs:3,2.5) {$h(x)$};
        \end{axis}
    \end{tikzpicture}
};
\end{tikzpicture}

\end{document}
