如何将该物体置于其他所有物体的后面?

如何将该物体置于其他所有物体的后面?

是否可以将带有颜色渐变的矩形放在其他所有内容之下?

在此处输入图片描述

\documentclass[11pt]{article}
\usepackage{pgfplots}
\usepgfplotslibrary{colormaps}
\pgfplotsset{compat=newest}

\begin{document}
\centering
\begin{tikzpicture}
\begin{axis}[
    yticklabel pos=left,grid=major,
    ]
    \fill[
        right color=white, 
        left color=white,
        middle color=blue!30, 
    ] (4.,-1) rectangle (6,6);
    \addplot [blue, domain=0:10] {.5*x+2};
    \addplot [red, dashed, domain=0:10] {x-3};
\end{axis}
\end{tikzpicture}
\end{document}

答案1

\documentclass[tikz, border=1cm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
set layers,
yticklabel pos=left,grid=major,
]
\pgfonlayer{axis background}
\fill[right color=white, left color=white, middle color=blue!30] (4.,\pgfkeysvalueof{/pgfplots/ymin}) rectangle (6,\pgfkeysvalueof{/pgfplots/ymax});
\endpgfonlayer
\addplot [blue, domain=0:10] {.5*x+2};
\addplot [red, dashed, domain=0:10] {x-3};
\end{axis}
\end{tikzpicture}
\end{document}

带蓝色阴影条的图表

相关内容