1

The question is easy to explain with this MWE:

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 1};
\end{tikzpicture}
\begin{tikzpicture}[x=0.5cm, y=0.5cm]
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 2};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 3};
\end{tikzpicture}
\end{document}

which results in:

result of the mwe before

In the output, graph2 did quite surprise me --- it seems that the grid and the -- to draw lines are using different coordinates. I was expecting that the grid would scale down as the line do... what am I missing?

(BTW --- also the fact that in neither graph the text is scaling down is quite surprising).

Rmano
  • 40,848
  • 3
  • 64
  • 125

1 Answers1

4

every thing is good the point A is (3,3) since (1,1) is in (0.5cm,0.5cm) you can set the step=1 like this

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 1};
\end{tikzpicture}
\begin{tikzpicture}[x=0.5cm, y=0.5cm]
 \draw [very thin, color=gray, dashed, step=1] (0, 0) grid (5, 5);  % ---> step=1
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 2};
\end{tikzpicture}
\begin{tikzpicture}[scale=0.5]
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 3};
\end{tikzpicture}
\end{document} 

Edit: for text scaleing you can see How to scale a tikzpicture including texts?

enter image description here

Edit about grid (this is only 1st tikzpicture)

\documentclass{standalone}
\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
 \draw [very thin, color=gray, dashed] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 1};
\end{tikzpicture}

\begin{tikzpicture}
 \draw [very thin, color=gray, dashed,step=0.5] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 1};
\end{tikzpicture}

\begin{tikzpicture}
 \draw [very thin, color=gray, dashed,step=0.2] (0, 0) grid (5, 5);
 \draw [color=green!50!black, ->] (0, 0) -- (3,3)  node[above right]{$\vec{A}$};
 \draw (0,5) node[below right]{graph 1};
\end{tikzpicture}
\end{document} 

enter image description here

touhami
  • 19,520
  • Thanks --- but I really still do not understand --- so the coordinates for grid and -- are different by default? And why your example has text scaled --- I can't spot the difference from my mwe in that sense... – Rmano Mar 15 '15 at 19:09
  • @Rmano in my code i use [x=0.5cm, y=0.5cm,every node/.style={scale=0.5}] and [scale=0.5,every node/.style={scale=0.5}] – touhami Mar 15 '15 at 19:35
  • @Rmano i edit my answer traying to more explain about grid you shoud know that the step of grid is different from the unit of coordinates. – touhami Mar 15 '15 at 19:43
  • I still do not see the every node key in the code you posted in any of your answer --- a copy and paste problem? – Rmano Mar 15 '15 at 20:03
  • i don't use it in the code posted but in the code used at home – touhami Mar 15 '15 at 20:12