TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

example of what I would like to achieve

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

\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);
share|improve this question
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
up vote 7 down vote accepted

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:

  \inheritsavedanchors[from=rectangle] % this is nearly a rectangle
  \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{\ttemp@x}{.5*(\pgf@xb-\pgf@xa)}    % construct main path
    \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);

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.

share|improve this answer

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.


        myCircle/.style={circle, draw, minimum size=2.5mm, inner sep=0pt},
            append after command={
                    \draw (\tikzlastnode.north-|\tikzlastnode.west) rectangle 
        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);

enter image description here

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.