I have a problem with horizontal grid lines in a graph (I am trying to overlay a 1cm x 1cm grid to my pages, and stumbled upon this in the process):

    \draw [help lines,red,ystep=1cm,xstep=1cm] (0,0) node{A} grid +(3cm, -3cm) node{B};
    \draw [help lines,blue,ystep=1cm,xstep=1cm] (0,0) node{A} grid +(3cm, 3cm) node{B};
    \draw [help lines,green,ystep=-1cm,xstep=1cm] (0,0) node{A} grid +(3cm, -3cm) node{B};

with this result:

three strange grids

Notice that the green grid has a negative ystep as suggested in Grid missing horizontal lines, but still I have no lines.

So I decided that I probably do not understand how grids are generated; can someone shed some light here?

  • Do you really get this image from your MWE? I am getting errors and another output. Please check! – LaRiFaRi Apr 10 '15 at 10:38
  • @LaRiFaRi re-checked by cutting and pasting in a new file. I have TeXlive 2013 on an Ubuntu 14.04.2 desktop. No errors. Puzzled. – Rmano Apr 10 '15 at 10:43
  • @Rmano: You might want to upgrade your TikZ package to 3.0. On Overleaf, the third image gives an error, but the first two yield the same (correct) result: overleaf.com/2526302tzgdwx#/6615464 – Jake Apr 10 '15 at 10:51

Please update your TikZ version. You should not use negative steps if your vectors are not defined in negative directions. Just do like the following in order to span the grid:

% arara: pdflatex


    \begin{scope} % south west to north east
        \draw [help lines,red,ystep=1cm,xstep=1cm] (0,0) node{A} grid +(3,3) node{B};
    \begin{scope} % north west to south east
        \draw [help lines,blue,ystep=1cm,xstep=1cm] (4,3) node{A} grid +(3,-3) node{B};
    \begin{scope} % north east to south west
        \draw [help lines,green,ystep=1cm,xstep=1cm] (11,3) node{A} grid +(-3,-3) node{B};
    \begin{scope} % south east to north west
        \draw [help lines,ystep=1cm,xstep=1cm] (15,0) node{A} grid +(-3,+3) node{B};

enter image description here

| improve this answer | |
  • Althoug I think that this is the correct answer --- with my current tikz using ` \draw [help lines,green,ystep=1cm,xstep=1cm] (0, -3cm) grid (3cm, 0) (0, 0) node {A} (3cm, -3cm) node {B};` --- IOW, specifying always `(bottom left corner) grid (upper right corner). Thanks. – Rmano Apr 10 '15 at 11:06

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.