2

I'm trying to put a parallellogram into a coordinate system, so that it starts from the bottom left corner of the trapezoid. However, the problem is that the coordinate axis do not start from that corner, and I don't seem to get the x axis right either.

Does anyone have any ideas of how this can be solved?

\begin{tikzpicture}
\node (a) [shape=trapezium, draw, minimum width=3cm, trapezium right angle=120, trapezium left angle=60] {};
\node (b) [below left] at (a.bottom left corner) {};
\node (d) [below left] at (a.bottom right corner) {};
\node (c) at (b |- 3,2)  {B};
\node (e) at (d |- 3,2)  {E};
%\draw (b |- ,2) node {B};
\draw[->] (b) -- (c);
\draw[->] (b) -- (3,-1);
%\draw [->] b -- ++ (1,2);
\end{tikzpicture}

enter image description here

Torbjørn T.
  • 206,688
Artem
  • 123
  • At the moment I see a parallelogram but no trapezium (in its usual meaning) –  Feb 04 '17 at 10:18
  • The reason the axis lines doesn't meet is the same problem described in http://tex.stackexchange.com/questions/99398/why-dont-my-tikz-lines-join – Torbjørn T. Feb 04 '17 at 10:24

2 Answers2

5

You seem to make this more complicated that it needs be, you can use relative coordinates to draw a horizontal and a vertical line starting in the corner.

The reason the axis lines doesn't start in the corner is a combination of the fact that your b node is placed below left of the corner, and that nodes have a non-zero size by default, as described in Why don't my TikZ lines join?

enter image description here

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\begin{document}
\begin{tikzpicture}
\node (a) [shape=trapezium, draw, minimum width=3cm, trapezium right angle=120, trapezium left angle=60] {};

\draw [->] (a.bottom left corner) -- +(0,2) node[above] (b) {B};
\draw [->] (a.bottom left corner) -- +(4,0);

\node at (b-|a.bottom right corner) {E};

\end{tikzpicture}
\end{document} 
Torbjørn T.
  • 206,688
4

Firstly, I agree with Torbjørn that you should use relative coordinates directly. However, in a more complicated picture you might want to set new coordinates. The problem you encouter here is that even an empty node takes up a space. You can solve this in some different ways, e.g. set the node space to zero by inner sep=0pt, or use \coordinate (which essentially is a node without space and argument). Here I use coordinate. (I have also printed some of the coordinates for help, and set E where I think it is better suited).

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes}
\begin{document}

\begin{tikzpicture}
  \node (a) [shape=trapezium, draw, minimum width=3cm, trapezium right angle=120, trapezium left angle=60] {};
  \coordinate (b) at (a.bottom left corner);
  \coordinate (d) at (a.bottom right corner);
  \draw[->] (b) -- +(0,2) node[above]{B};
  \draw[->] (b) -- +(3,0) node[right]{E};
  %% 
  \draw[red] (a.center) circle (1pt) node[anchor=north east]{a};
  \draw[red] (b) circle (1pt) node[anchor=north east]{b};
  \draw[red] (d) circle (1pt) node[anchor=north east]{d};
\end{tikzpicture}

\end{document}

enter image description here

StefanH
  • 13,823