I inverted the vertical axis in Tikz for convenience, and then tried to draw a simple grid:


    \draw[step=1] (0,0) grid (4,4);

For some reason I got all the vertical lines and one horizontal line:

enter image description here

Dropping the [y=-1cm] bit gives me the desired output:

enter image description here

Is it a bug? How can I keep the inverted vertical axis while drawing a grid?

  • Do you not get a compilation error? Can you please post a complete example? When I try to complete yours with a minimal wrapper, it does not compile at all. – cfr Oct 15 '15 at 22:27
  • 1
    Your code produces an error. What you are trying to do can be achieved with \begin{tikzpicture}[yscale=-1] \draw[step=1] (0,0) grid (4,4); \end{tikzpicture}. – Gonzalo Medina Oct 15 '15 at 22:29
  • I edited the question with the entire code. Have no issues with compiling it (MiKTeX, pdflatex)... – Daniel Oct 15 '15 at 22:36
  • @GonzaloMedina, your solution also works for me, thank you! – Daniel Oct 15 '15 at 22:37
  • @Zarko This looks like a bug to me. If it is not, how can we explain that replacing [y=-1cm] with [yscale=-1] works fine ? – Kpym Oct 16 '15 at 19:56

I actually managed to fix the problem by changing the vertical step to -1 and swapping the y coordinates of the grid:

    \draw[xstep=1,ystep=-1] (0,4) grid (4,0);

but to me this looks like a bug in Tikz.

  • A bug? I doubt. I thing that you request from TikZ two opposite action at the same time, and this confuse it. It cannot be posivite steps with negative value ... – Zarko Oct 15 '15 at 23:14

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.