I have the following code to draw four axes:
\begin{tikzpicture}
\draw (-3,0) -- (3,0) node[below];
\draw[shift={(0,0)}] (0pt,2pt) -- (0pt,-2pt) node[below];
\draw (0,-3) -- (0,3) node[left];
\draw[shift={(0,0)}] (2pt,0pt) -- (-2pt,0pt) node[left];
\node[below] at (0,-3.20) {\footnotesize label1};
\node[above] at (0,3.20) {\footnotesize label2};
\node[right] at (3.20, 0) {\footnotesize label3};
\node[left] at (-3.20, 0) {\footnotesize label4};
\end{tikzpicture}
When compiling, I got the following error:
"! Package tikz Error: A node must have a (possibly empty) label text"
Is there another error free way of labeling?
Best Answer
You need to give a label text to a
node
, an empty one{}
would be enough:If you just want a named position, you can simply use
coordinate
. In your case, nodes in the\draw
commands seems unnecessary (they don't have label texts and come with no name to be referred to later), an easier way is to draw the nodes inside paths: