我如何填充像图像那样的颜色?
\begin{tikzpicture}
\draw (0,-1)--(0,7)
\draw (0,6)--(8,6) node [pos=0, left] {\(L-\varepsilon\)};
\draw (-1,5)--(8,5) node [pos=0, left] {\(L\)};
\draw (0,4)--(8,4) node [pos=0, left] {\(L+\varepsilon\)};
\draw (0, 2)--(8,2) node [pos=0, left] {\(M-\varepsilon\)};
\draw (-1, 1)--(8,1) node [pos=0, left] {\(M\)};
\draw (0,0)--(8,0) node [pos=0, left] {\(M+\varepsilon\)};
\node (1) at (8,3) {\(\varepsilon=\frac{1}{3}\abs{L-M}\)};
\end{tikzpicture}
答案1
填充物是阴影吗?
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\shade [shading=axis,shading angle=90] (0,0) rectangle (8,2);
\shade [shading=axis,shading angle=90] (0,4) rectangle (8,6);
\draw (0,-1)--(0,7);
\draw (0,6)--(8,6) node [pos=0, left] {\(L-\varepsilon\)};
\draw (-1,5)--(8,5) node [pos=0, left] {\(L\)};
\draw (0,4)--(8,4) node [pos=0, left] {\(L+\varepsilon\)};
\draw (0, 2)--(8,2) node [pos=0, left] {\(M-\varepsilon\)};
\draw (-1, 1)--(8,1) node [pos=0, left] {\(M\)};
\draw (0,0)--(8,0) node [pos=0, left] {\(M+\varepsilon\)};
\node (1) at (8,3) {\(\varepsilon=\frac{1}{3}\abs{L-M}\)};
\end{tikzpicture}
\end{document}
或者是一种模式?
\documentclass{article}
\usepackage{mathtools}
\DeclarePairedDelimiter\abs{\lvert}{\rvert}%
\usepackage{tikz}
\usetikzlibrary{fadings,patterns}
\tikzfading[name=fade right,
left color=transparent!100,
right color=transparent!0]
\begin{document}
\begin{tikzpicture}
\fill [black!20] (0,0) rectangle (8,2);
\path [pattern=checkerboard,pattern color=black!40]
(0,0) rectangle (8,2);
\fill [white,path fading=fade right] (0,0) rectangle (8,2);
\fill [black!20] (0,4) rectangle (8,6);
\path [pattern=checkerboard,pattern color=black!40]
(0,4) rectangle (8,6);
\fill [white,path fading=fade right] (0,4) rectangle (8,6);
\draw (0,-1)--(0,7);
\draw (0,6)--(8,6) node [pos=0, left] {\(L-\varepsilon\)};
\draw (-1,5)--(8,5) node [pos=0, left] {\(L\)};
\draw (0,4)--(8,4) node [pos=0, left] {\(L+\varepsilon\)};
\draw (0, 2)--(8,2) node [pos=0, left] {\(M-\varepsilon\)};
\draw (-1, 1)--(8,1) node [pos=0, left] {\(M\)};
\draw (0,0)--(8,0) node [pos=0, left] {\(M+\varepsilon\)};
\node (1) at (8,3) {\(\varepsilon=\frac{1}{3}\abs{L-M}\)};
\end{tikzpicture}
\end{document}