1

I want to draw a system of coordinates with TikZ. At the moment I use the following code (which I copied from somewhere). Now I would like to make the minus signs on the negative y-coordinates more visible, e.g. by moving the label slightly below. How would I achieve that?

\begin{tikzpicture}[scale=1.7]
\draw[step=.5cm,help lines,dashed] (-2.4,-2.4) grid (2.4,2.4); 
\draw (0.1, 0) node[anchor=north] {$0$}; 
\draw[thick, ->] (-2.5,0) -- (2.5,0) node[below] {x}; \draw[thick, ->] (0,-2.5) -- (0,2.5) node [left] {y}; 
\foreach \x/\xtext in {-4,-3,-2,-1,1, 2,3,4}
   \draw (0.5 * \x cm,1pt) -- (0.5 * \x cm,-1pt) node[anchor=north] {$\xtext$};
\foreach \y/\ytext in {-4,-3, -2, -1, 1, 2, 3,4}
   \draw (1pt,\y*0.5 cm) -- (-1pt,\y*0.5 cm) node[anchor=north]{$\ytext$};
\end{tikzpicture}
6
  • 2
    I don't understand your question. Minus signs look visible enough to me.
    – JLDiaz
    May 28, 2014 at 8:11
  • Sorry, wrong code. But somehow I think, they are too far away. May 28, 2014 at 8:13
  • use inner sep=1pt or whatever you feel right
    – JLDiaz
    May 28, 2014 at 8:16
  • @JLDiaz inner sep=1pt only shifts the label on the diagonal axis for anchor=north east. I would like to shift it in other directions. May 28, 2014 at 8:29
  • Then use xshift and yshift options, or just shift={(-3mm,-2mm)} or whatever
    – JLDiaz
    May 28, 2014 at 8:42

1 Answer 1

2

Even if I don't fully understand the problem, you can apply xshift or yshift to a node to displace where is finally put (unless you are using named coordinates to specify the node coordinates, which is not your case). So, for example:

\foreach \y/\ytext in {-4,-3, -2, -1, 1, 2, 3,4}
   \draw (1pt,\y*0.5 cm) -- (-1pt,\y*0.5 cm) 
       node[xshift=-3mm, yshift=2mm, anchor=north]{$\ytext$};

This can be shortened if you use shift option:

\foreach \y/\ytext in {-4,-3, -2, -1, 1, 2, 3,4}
   \draw (1pt,\y*0.5 cm) -- (-1pt,\y*0.5 cm) 
       node[shift={(-3mm, 2mm)}, anchor=north]{$\ytext$};

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.