Axis 和 Tikz 格式

Axis 和 Tikz 格式
\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[fleqn]{amsmath}
\usepackage{tikz}


\begin{document}


\begin{tikzpicture}

\draw[step = 0.4cm, gray, very thin] (-2,-2) grid (6,6);

\draw[thick,->] (0,0) -- (4.5,0) node[anchor = north west]{x axis};
\draw[thick,->] (0,0) -- (0,4.5) node[anchor = south east]{y axis};

\foreach \x in {0,1,2,3}
    \draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$)};
\foreach \y in {0,1,2,3,4}
    \draw (1pt, \y cm) -- (-1pt, \y cm) node[anchor = east] {$\y$)};

\end{tikzpicture}

\end{document}

如何去掉这段代码中的括号?

来源:https://www.youtube.com/watch?v=pcIzeN46ETc[5:48-6:42]

在此处输入图片描述

答案1

\documentclass[a4paper,12pt]{article}

\usepackage[utf8]{inputenc}
\usepackage[fleqn]{amsmath}
\usepackage{tikz}


\begin{document}


\begin{tikzpicture}

\draw[step = 0.4cm, gray, very thin] (-2,-2) grid (6,6);

\draw[thick,->] (0,0) -- (4.5,0) node[anchor = north west]{x axis};
\draw[thick,->] (0,0) -- (0,4.5) node[anchor = south east]{y axis};

\foreach \x in {0,1,2,3}
    \draw (\x cm, 1pt) -- (\x cm, -1pt) node[anchor = north] {$\x$};
\foreach \y in {0,1,2,3,4}
    \draw (1pt, \y cm) -- (-1pt, \y cm) node[anchor = east] {$\y$};

\end{tikzpicture}

\end{document}

相关内容