在 tikz 中向网格添加坐标

在 tikz 中向网格添加坐标

有没有一种简单的方法可以在 tikz 中向网格添加坐标(左和下)?

答案1

我认为这就是想要的:

\documentclass[tikz]{standalone}
\begin{document}
%
\begin{tikzpicture}
% Draw the grid
\tikzset{help lines/.style={color=blue!50}}
\draw[thick,step=1cm,help lines] (0,0) grid (9,9);
\draw[ultra thin,step=.5cm,help lines] (0,0) grid (9,9);
% Draw axes
\draw[ultra thick,-latex] (0,0) -- (10,0);
\draw[ultra thick,-latex] (0,0) -- (0,10);
% the co-ordinates -- major
\foreach \x in {0,1,...,9} {     % for x-axis
\draw [thick] (\x,0) -- (\x,-0.2);
}
\foreach \y in {0,1,...,9} {   %% for y-axis
\draw [thick] (0,\y) -- (-0.2,\y);
}
% the numbers
\foreach \x in {0,1,...,9} { \node [anchor=north] at (\x,-0.3) {\x}; }
\foreach \y in {0,1,...,9} { \node [anchor=east] at (-0.3,\y) {\y}; }
% the co-ordinates -- minor
\foreach \x in {.5,1.5,...,8.5} {
\draw [thin] (\x,0) -- (\x,-0.1);
}
\foreach \y in {.5,1.5,...,8.5} {
\draw [thin] (0,\y) -- (-0.1,\y);
}
\end{tikzpicture}
%
\end{document}

在此处输入图片描述

相关内容