Code: Select all
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\m{5}
\pgfmathsetmacro\n{4}
\begin{axis}[
xmin=0, xmax=\m, ymin=0, ymax=\n,
xtick pos=left,ytick pos=bottom,
grid = major, axis line style={draw=none},
]
% dots:
\foreach \i in {0,...,\m}
\foreach \j in {0,...,\n} {
\addplot+[mark=*,only marks, mark options={color=blue}] coordinates {(\i,\j)};
}
% left arrows:
\foreach \i in {0,...,\inteval{\m - 1}}
\foreach \j in {0,...,\n} {
\draw[->, blue, thick] (axis cs: \inteval{\i}, \inteval{\j}) -- (axis cs: \inteval{\i+1}, \inteval{\j});
}
\end{axis}
\end{tikzpicture}
\end{document}
Code: Select all
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{arrows.meta}
\begin{document}
\begin{tikzpicture}
\pgfmathsetmacro\m{5}
\pgfmathsetmacro\n{4}
\begin{axis}[
xmin=0, xmax=\m, ymin=0, ymax=\n,
xtick pos=left,ytick pos=bottom,
grid = major, axis line style={draw=none},
]
% dots:
\foreach \i in {0,...,\m}
\foreach \j in {0,...,\n} {
\addplot+[mark=*,only marks, mark options={color=blue}] coordinates {(\i,\j)};
}
% left arrows:
\foreach \i in {0,...,\inteval{\m - 1}}
\foreach \j in {0,...,\n} {
\draw[->, blue, thick] (axis cs: \i, \j) -- (axis cs: \fpeval{\i+1}, \j);
}
\end{axis}
\end{tikzpicture}
\end{document}