# How can I create a diagram to compare skyline operation results using LaTeX?

I'm trying to draw this but except for the straight lines in this diagram I'm not able to place other things such as square and circle properly. How can I do this? Help much appreciated.

EDIT: Since MWE is asked I'll post here my code and update it as and when I get close to the picture above.

\documentclass{minimal}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}[y=.2cm, x=.7cm,font=\sffamily]
\draw (0,0) -- coordinate (x axis mid) (10,0);
\draw (0,0) -- coordinate (y axis mid) (0,30);
\end{tikzpicture}
\end{document}

-
Could you post what you have so far? It's always nice for folks to have a starting point :) – cmhughes Nov 1 '11 at 18:37
It is always best to compose a MWE that illustrates what you have done so far, so that those trying to help don't have to recreate it. – Peter Grill Nov 1 '11 at 18:39
I'd have put that but all I got is just a x and y axis. I could draw circles and squares separately but I'm not sure how to place them. – Sunil Nov 1 '11 at 18:46
Good start. Now add \draw (0,20) circle (5pt) node [left] {$t_2$} to place the circle. – Peter Grill Nov 1 '11 at 18:57
Is there some specific name for this type of diagram? Because in the current form nobody that wants to create something similar is ever going to find this question, making it relatively useless. The question title would be better as How can I create a <diagramname> diagram using LaTeX?. – Roelof Spijker Nov 1 '11 at 20:35

You can use the following code. The circles are created using nodes and we draw to and from the nodes, because then the line does not go through it. For the circle in the rectangle we define a new shape so we can just use nodes for that as well. The code looks like this:

\documentclass{article}
\usepackage{tikz}
\begin{document}
\makeatletter
\pgfdeclareshape{rectCircle}{
\inheritsavedanchors[from=rectangle] % this is nearly a rectangle
\inheritanchorborder[from=rectangle]
\inheritanchor[from=rectangle]{center}
\inheritanchor[from=rectangle]{north}
\inheritanchor[from=rectangle]{south}
\inheritanchor[from=rectangle]{west}
\inheritanchor[from=rectangle]{east}
\backgroundpath{% this is new
% store lower left in xa/ya and upper right in xb/yb
\southwest \pgf@xa=\pgf@x \pgf@ya=\pgf@y
\northeast \pgf@xb=\pgf@x \pgf@yb=\pgf@y

\pgfmathsetmacro{\temp@x}{\pgf@xa+.5*(\pgf@xb-\pgf@xa)}
\pgfmathsetmacro{\ttemp@x}{.5*(\pgf@xb-\pgf@xa)}    % construct main path
\pgfpathmoveto{\pgfpoint{\pgf@xa}{\pgf@ya}}
\pgfpathlineto{\pgfpoint{\pgf@xa}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@yb}}
\pgfpathlineto{\pgfpoint{\pgf@xb}{\pgf@ya}}
\pgfpathclose
\pgfpathmoveto{\pgfpoint{\temp@x}{\pgf@ya}}
\pgfpatharc{270}{-90}{\ttemp@x}
}
}
\makeatother
\begin{tikzpicture}[font=\sffamily]
\node [circle, draw, minimum size=2.5mm, inner sep=0pt] (t1) at (3,0) {};
\node [rectCircle, draw] (t5) at (0,2) {};
\node [circle, draw, minimum size=2.5mm, inner sep=0pt] (t2) at (0,3) {};
\node [circle, draw, minimum size=2.5mm, inner sep=0pt] (t4) at (2,2) {};
\node [rectCircle, draw] (t3) at (2,1) {};
\coordinate (orig) at (0,0);
\draw (orig) -- (t1) node [below=2mm] {$t_1$};
\draw [->] (t1) -- ++(0.5,0);
\draw (orig) -- (t5) node[left=2mm]{$t_5$} -- (t2) node[left=2mm] {$t_2$};
\draw [->] (t2) -- ++(0,0.5);
\draw [dashed] (t5) -- (t4) node[right=2mm] {$t_4$} -- (t3) node[right=2mm] {$t_3$};
\draw [dashed] (t2) -- ++(3,0) node {$\times$} -- (t1);
\end{tikzpicture}
\end{document}


And the resulting image looks like this:

The most difficult part is the creation of the new node shape, I suppose. This could probably also be done by using overlay and remember picture and drawing the nodes on top of each other. That would require very precise sizing though and wouldn't scale as easily as creating a new shape. Creating the legend is left as an exercise for the reader, should be relatively straightforward now all of the nodes are available.

-

Following code shows an alternative way for creating a rectCircle shape. Instead of declaring a new shape, just a style with an append after command option can serve.

Also a cross style has been declared which will replace $\times$ in Roelof's solution.

\documentclass[border=2mm,tikz]{standalone}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}

\begin{document}
\begin{tikzpicture}[font=\sffamily,
myCircle/.style={circle, draw, minimum size=2.5mm, inner sep=0pt},
rectCircle/.style={myCircle,
append after command={
\pgfextra
\draw (\tikzlastnode.north-|\tikzlastnode.west) rectangle
(\tikzlastnode.south-|\tikzlastnode.east);
\endpgfextra}},
cross/.style={cross out, minimum size=1.5mm, draw, inner sep=0pt, solid}
]
\node [myCircle] (t1) at (3,0) {};
\node [rectCircle, draw] (t5) at (0,2) {};
\node [myCircle] (t2) at (0,3) {};
\node [myCircle] (t4) at (2,2) {};
\node [rectCircle, draw] (t3) at (2,1) {};
\coordinate (orig) at (0,0);
\draw (orig) -- (t1) node [below=2mm] {$t_1$};
\draw [->] (t1) -- ++(0.5,0);
\draw (orig) -- (t5) node[left=2mm]{$t_5$} -- (t2) node[left=2mm] {$t_2$};
\draw [->] (t2) -- ++(0,0.5);
\draw [dashed] (t5) -- (t4) node[right=2mm] {$t_4$} --(t3) node[right=2mm] {$t_3$};
\draw [dashed] (t2) -- ++(3,0) node[cross] {} -- (t1);
\end{tikzpicture}
\end{document}


-