\documentclass{article}
\usepackage{tikz}
\begin{document}
\begin{figure}[h]
\centering
\begin{tikzpicture}[scale=1]
% Define the function
\draw[domain=0:4, smooth, thick, color=blue] plot (\x, {(\x-2)^2});
% Define the intervals
\draw[dashed, color=gray] (0,0) -- (4,0);
\foreach \x in {0, 1, 2, 3, 4}
\draw[dashed, color=gray] (\x,0) -- (\x,4);
% Define the left endpoints of each interval
\foreach \x in {0, 1, 2, 3}
\draw[fill=gray, opacity=0.5] (\x,0) rectangle (\x+1, {((\x)-2)^2});
% Label the axes
\draw[->] (0,0) -- (4.5,0) node[right] {$x$};
\draw[->] (0,0) -- (0,5) node[above] {$y$};
% Label the function
\node at (2,4.5) {$y = (x-2)^2$};
\end{tikzpicture}
\caption{Riemann sum using left endpoints}
\end{figure}
\end{document}
This code will generate a figure that illustrates the concept of a Riemann sum using the left endpoints of each interval on the x-axis to give the heights of the rectangles. The function y=(x−2)2 is plotted over the interval [0,4], and the left endpoints of each subinterval are used to determine the height of the corresponding rectangle. The rectangles are filled with gray and have an opacity of 0.5 to make them semi-transparent. The x and y axes are labeled, and the function is labeled above the plot.