答案1
欢迎来到 TeX.SE!由于这是标记的,pgfplots
因此可以使用此包创建此类内容。
\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xmin=-1.1,xmax=1.1,ymin=-1.1,ymax=1.1,
grid=both,minor tick num=4,xtick={-1,0,1},ytick={-1,0,1},axis lines=middle,
major grid style={thick}]
\addplot[color=purple,thick,name path=upper] {x+1/2};
\addplot[color=purple,thick,name path=lower] {x-1/2};
\addplot[purple,opacity=0.6] fill between [of=upper and lower];
\end{axis}
\end{tikzpicture}
\end{document}