%\documentclass{article}
\documentclass[border=5]{standalone}
\usepackage{pgfplots} %http://www.ctan.org/pkg/pgfplots
\pgfplotsset{compat=newest, set layers=standard}

\begin{document}

\pgfplotsset{
    integral axis/.style={
        axis lines=middle,
        enlarge y limits=upper,
        axis equal image, width=12cm,
        xlabel=$x$, ylabel=$y$,
        ytick=\empty,
        xticklabel style={font=\small, text height=1.5ex, anchor=north},
        samples=100
    },
    integral/.style={
            domain=2:6,
            samples=9
    },
    integral fill/.style={
            integral,
            draw=none, fill=#1,
            on layer=axis background
        },
        integral fill/.default=blue!20,
        integral line/.style={
            integral,
            very thick,
            draw=#1
        },
        integral line/.default=black
}


\begin{tikzpicture}[
    % The function that is used for all the plots
    declare function={f=x/5-cos(deg(x*1.85))/2+2;}
]
\begin{axis}[
    integral axis,
    ymin=0,
    xmin=0.75, xmax=7.25,
    domain=1.5:6.5,
    xtick={2,2.5,...,6},
    xticklabels={$a=x_0$, $x_1$,,,$x_{i-1}$,$x_i$,,$x_{n-1}$,$b=x_n$},
]
% The function
\addplot [very thick, blue] {f} node [anchor=north] {$y=f(x)$};

% The filled area under the approximate integral
\addplot [integral fill=blue!20] {f} \closedcycle;

% The approximate integral
\addplot [integral line=black] {f};

% The vertical lines between the segments
\addplot [integral, ycomb] {f};

% The highlighted segment
\addplot [integral fill=blue!50, domain=4:4.5, samples=2] {f} \closedcycle;
\end{axis}
\end{tikzpicture}

\end{document}