# How to draw visual representation of relations with TikZ

My included graphics are too blurry so I decided to find out, how to draw the following four graphics in TikZ. I never really worked with TikZ, so can someone explain how to draw such graphics?

-
You should add a Minimal Working Example and say what is exactly your problem or what you don't know to do. –  Manuel Dec 18 '12 at 1:37
You are welcome but what exactly is the question? –  percusse Dec 18 '12 at 1:37
@percusse: Added the question. –  Christian Ivicevic Dec 18 '12 at 1:43

Here's one possibility:

\documentclass{article}
\usepackage{amssymb}
\usepackage{tikz}

\def\mysquare#1{%
\node[draw,minimum width=3cm,minimum height=3cm] (#1) {};
\draw[->] (#1.east) -- +(10pt,0) node[label=below :$\mathbb{R}$] {};
\draw (#1.west) -- +(-10pt,0);
\draw[->] (#1.north) -- +(0,10pt) node[label=right :$\mathbb{R}$] {};
\draw (#1.south) -- +(0,-10pt);
}

\begin{document}
\begin{tikzpicture}[>=latex]
\mysquare{a}
\draw (a.north west)  -- node[auto,swap,midway] {$R_1$} +(1.5cm,-1.5cm) -- (a.north east);
\begin{scope}[xshift=5cm]
\mysquare{b}
\draw (b.north east)  -- node[auto,swap,midway] {$R_1^{-1}$} +(-1.5cm,-1.5cm) -- (b.south east);
\end{scope}
\begin{scope}[yshift=-5cm]
\mysquare{c}
\filldraw[draw=black,fill=blue!20] (c.north east)  -- (c.north west) -- (c.south west) -- cycle;
\node at ([xshift=15pt,yshift=-15pt]c.north west) {$R_2$};
\end{scope}
\begin{scope}[xshift=5cm,yshift=-5cm]
\mysquare{d}
\filldraw[draw=black,fill=blue!20] (d.north east)  -- (d.south west) -- (d.south east) -- cycle;
\node at ([xshift=-15pt,yshift=15pt]d.south east) {$R_2^{-1}$};
\end{scope}
\end{tikzpicture}

\end{document}


-