2

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

\documentclass{article}
\usepackage{tikz}

\begin{document}
\begin{tikzpicture}[y=-1cm]
    \draw[step=1] (0,0) grid (4,4);
\end{tikzpicture}
\end{document}

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?

5
  • 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, 2015 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}. Oct 15, 2015 at 22:29
  • I edited the question with the entire code. Have no issues with compiling it (MiKTeX, pdflatex)...
    – Daniel
    Oct 15, 2015 at 22:36
  • @GonzaloMedina, your solution also works for me, thank you!
    – Daniel
    Oct 15, 2015 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, 2015 at 19:56

1 Answer 1

2

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

\begin{tikzpicture}[y=-1cm]
    \draw[xstep=1,ystep=-1] (0,4) grid (4,0);
\end{tikzpicture}

but to me this looks like a bug in Tikz.

1
  • 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, 2015 at 23:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .