答案1
使用循环的另一种方法\foreach
:
\documentclass[border=5pt]{standalone}
\usepackage{tikz}
\tikzset{%
every node/.style={font=\strut},
}
\begin{document}
\begin{tikzpicture}
\foreach \x [count=\i from 1] in {1,...,7} {%
\foreach \y [count=\ii from 1] in {1,...,4} {%
\draw[fill=black] (\x,\y) circle[radius=1pt] node (circ-\i-\ii) {};
\draw (1,\y) -- (7,\y);
\draw (\x,1) -- (\x,4);
}
}
\node[below] at (circ-1-1) {$x_0=a$};
\node[below] at (circ-7-1) {$x_{n+1}=b$};
\node[below=10pt, orange] at (circ-4-1) {known values};
\node[below] at (circ-4-1) {$t=0$};
\node[above] at (circ-4-4) {$t_m=T$};
\draw[orange, fill=orange, opacity=0.25] (0.875,0.875) rectangle (7.125,1.125);
\end{tikzpicture}
\end{document}