I'm trying to reproduce the following two figures in TikZ.
My attempted code for Fig 1 is
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [fill=black, ultra thick, red] (0.0,0.0) -- (0.5, 0.5) -- (0.5, 1.5) -- (0.0, 1.0) -- cycle;
\draw [fill=black, ultra thick, blue] (1.0,0.0) -- (1.5, 0.5)-- (1.5, 1.5)--(1.0, 1.0)--cycle;
\draw (0.0,0.0) -- (1.0, 0.0)-- (1.5, 0.5)--(0.5, 0.5)--cycle;
\draw (0.0,1.0) -- (1.0, 1.0)-- (1.5, 1.5)--(0.5, 1.5)--cycle;
\end{tikzpicture}
\end{document}
and for the second figure the code is
\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\draw [fill=black, ultra thick, red] (1.0,0.0) -- (1.0, 1.0) -- (0.5, 1.5) -- (0.5, 0.5) -- cycle;
\draw [fill=black, ultra thick, blue] (0.0,0.0) -- (0.0, 1.0)-- (1.5, 1.5)--(1.5, 0.5)--cycle;
\draw (0.0,0.0) -- (1.0, 0.0)-- (1.5, 0.5)--(0.5, 0.5)--cycle;
\draw (0.0,1.0) -- (1.0, 1.0)-- (1.5, 1.5)--(0.5, 1.5)--cycle;
\draw (1.0, 0.0) -- (1.0, 1.0) (0.5, 0.5) -- (0.5, 1.5);
\end{tikzpicture}
\end{document}
I'm a TikZ newbie and have troubles to produce exactly the same figures with more efficient code. I've a problem with overlays and exact coordinates. I'd highly appreciate if you could help me to fix these problems and get similar figures with more robust code.
Best Answer
It is often forgotten that tikZ also has an
xyz
coordinate system. I think it lets you express the coordinates in a more natural way. (I also added the circles.)