I'm trying to understand how the coordinate system work for drawing pictures with tikz. I'm a little lost...
Here is a MWE that shows of some example code:
\documentstyle{article}
\begin{document}
\usetikzlibrary{shapes}
\usetikzlibrary{backgrounds,fit,shapes}
\usetikzlibrary{positioning}
\begin{tikzpicture}
\tikzstyle{Y} = [rectangle, fill=orange!30!white]
\tikzstyle{X} = [rectangle, fill=green!30!white]
\tikzstyle{Other} = [rectangle, fill=blue!30!white]
\draw [help lines] (0,0) grid (100,10);
\node [Y, anchor=south west, minimum width=200,minimum height=10] (Response) at (0,0) {};
\node [below=of Response] {\small Variation in response};
\node [X, anchor=south west, minimum width=75,minimum height=10] (Explanatory) at (0,0) {};
\node [above=of Explanatory] {\small Explanatory};
\node [Other, anchor=south west, minimum width=50,minimum height=10] (Other) at (75,0) {};
\node [above=of Other] {\small Other};
\end{tikzpicture}
\end{document}
This is what was expecting, and wanting:
- My first rectangle would start at coordinate (0,0) and end at (200, 10) because the width was set as 200 minimum, and height at 10 minimum, and the south west anchor was (0,0).
- My second rectangle would start at (0,0), and end at (75, 10) for the same reason.
- My third rectangle would start at (75, 0), because the rectangle is placed at (75, 0) and anchored "south west" like all others. But it doesn't even appear at all on my picture... it is way, way to the right (off the page). It starts somewhere I wasn't expecting.
That third point is where it breaks down for me. Can someone please explain? I'll try to explain my confusion further.
In the second rectangle, I assumed that the rectangle was starting at (0,0) and ending at (75, 10) because of the width and height I provide. But when I place the third rectangle at to start at (75, 0), it starts somewhere else; why is it somewhere different?
Probably an easy explanation, but I don't see it.
[I am trying to draw a rectangle, and then cut it into sub-rectangles. This is a MWE, so it is more involved than this, with things changing slide-by-slide in beamer. But that's the context.]
Thanks.
P.
\draw (x1,x2) rectangle (y1,y2);
where x an y are opposite points of your rectangle? You can also check thefill
option for\draw
or the\filldraw
command (e.g.\filldraw[fill=green!20!white, draw=green!40!black] (0,0) rectangle (2,1)
).minimum width=200
, but have not specified units. I suspect it is defaulting topt
, but the coordinates are incm
. Try adding nodes below10
, 20`, etc to see where there are -- I think that should make it clear what is going on.