\begin{tikzpicture}[domain=0:4]
\draw[->] (-0.1,0) -- (6,0) node[right] {$x$};
\draw[->] (0,-0.1) -- (0,6) node[above] {$y$};
\draw[scale=1,domain=0:5,smooth,variable=\x,black] plot ({\x},{\x});
\draw[black,-] (1,0,0) -- (1,1,0) node[midway,right] {};
\draw[black,-] (4,0,0) -- (4,4,0) node[midway,right] {};
\end{tikzpicture}
我需要为函数下方的区域着色,表示积分。如果可能的话,用渐变色着色
答案1
\documentclass[tikz,border=3.14mm]{standalone}
\begin{document}
\begin{tikzpicture}[domain=0:4]
\draw[->] (-0.1,0) -- (6,0) node[right] {$x$};
\draw[->] (0,-0.1) -- (0,6) node[above] {$y$};
\draw[left color=blue,right color=blue!30] (1,0) -- (1,1) -- (4,4) |-cycle;
\draw[scale=1,domain=0:5,smooth,variable=\x,black] plot ({\x},{\x});
\end{tikzpicture}
\end{document}