1

How can I draw a graph like the one in the picture? enter image description here

I'm fairly new to Latex and I only know that I can draw lines with \line or \hrule but I have no clue how to draw a graph like this...

In addition I would like to put two arrows in front of the horizontal line (in front of the day market), with some additional text (for two actions happening before the day market).

1
  • This is 'pretty' easy with Tikz
    – user31729
    Commented May 20, 2017 at 16:38

5 Answers 5

2

as starting point ...

\documentclass[tikz, margin=5pt]{standalone}
\usetikzlibrary{arrows.meta}

\begin{document}
\begin{tikzpicture}[
  TL/.style = {very thick, Bar[width=4mm]},% as Time Line :-)
tbox/.style = {font=\Large\bfseries\sffamily},
bbox/.style = {text width=4cm, align=left, inner sep=2mm}
                    ]
\draw[TL]                (-5,0) -- (5,0);
\draw[TL,densely dashed] (0,2mm) -- (0,-2mm);
%
\node [tbox,above]  at (-2.4,0) {DAY (DM)};
\node [tbox,above]  at ( 2.4,0) {NIGHT (CM)};
%
\node [bbox,below right] at (-5,0) {xx xx xx xxx xxx xxx xxx\\ 
                                    yy yy yyy yyy yyyy\\
                                    zzzzz zz zzzz z z zzz};
\node [bbox,below right] at (0,0) {xx xx xx xxx xxx xxx xxx\\
                                    yy yy yyy yyy yyyy\\
                                    zzzzz zz zzzz z z zzz};
\end{tikzpicture}
\end{document}

Edit: instead of >={Bar[width=4mm]} is defined new style for vectors: Vect/.style = {very thick, Bar[width=4mm]} and accordingly changed code for line.

enter image description here

0
0

As @Christian Hupfer mentioned, Tikz is a good package to use. Try checking out this question for drawing a number line using tikz, which sounds like it is similar to what you want to do (without the numbers of course). As for the text below the line, you could use a table or tabular environment to accomplish that. I hope that helps.

3
  • this more comment than answer ...
    – Zarko
    Commented May 20, 2017 at 17:54
  • @Zarko It's more like an incomplete answer. Lacking a MWE, I can't complete the code. But, it sounds like kayB may just be trying to get the general idea rather than a complete answer anyway. Commented May 20, 2017 at 17:56
  • mostly you have right ... see starting point in my answer, maybe you can now complete your answer (in the first place OP, to whom answer is intended :-) )
    – Zarko
    Commented May 20, 2017 at 18:13
0

I augmented the suggested code above with the following lines:

 \draw [very thick, <->]  (-5.5,0mm) -- (-5.5, -10mm);
 \draw [very thick, <->]  (-6.2,0mm) -- (-6.2, 10mm);
 \node [bbox,below right] at (-5.8,-1) {$\eta$};
 \node [bbox,above right] at (-6.5,1) {$\mu$};
 \end{tikzpicture}
 \end{frame}

With the following output:enter image description here

As you can see the arrows are bars (I guess this has to do with: \begin{tikzpicture}[>={Bar[width=4mm]} or did I make a mistake in the code for the arrows?)

So the last step would be to draw arrows and not bars for the first two elements.

PS: regarding the forum policy: Which is the right way to answer the suggestion in the answer to my question (with new code and a picture)? 1. Edit my question? 2. Comment the answer? or 3. Write an own answer as I did now?

4
  • I give only starting point, where i for shorter code use (now see inappropriate) code: >={Bar[width=4mm]}. beter is give a name to this type of line ends. Answer is corrected.
    – Zarko
    Commented May 20, 2017 at 22:36
  • sorry, I'm lost now in your comment ... I suggest you to edit your question or even better ask new one. on this way more people will see your problem and help you.
    – Zarko
    Commented May 20, 2017 at 22:50
  • With this code: \tikzset{>=stealth} \draw [very thick, <-] (-5.5,0mm) -- (-5.5, -10mm); \draw [very thick, <-] (-6.2,0mm) -- (-6.2, 10mm); \node [bbox,below right] at (-5.8,-1) {$\eta$}; \node [bbox,above right] at (-6.5,1) {$\mu$}; \end{tikzpicture} \end{frame} the first two elements are arrows....
    – kayB
    Commented May 20, 2017 at 22:50
  • sorry, I messed up my comment due to false edit...
    – kayB
    Commented May 20, 2017 at 22:59
0

This gives the graph I planned to have. The code is based on the (original) answer of @Zarko:

 \begin{frame}
\frametitle{The Economy - Environment}
\center
\begin{tikzpicture}[>={Bar[width=4mm]},
tbox/.style ={font=\Large\bfseries\sffamily},
bbox/.style ={text width=4cm, align=left, inner sep=2mm}
                    ]
\draw[very thick,<->]  (-5,0) -- (5,0);
\draw[very thick,densely dashed]                     (0,2mm) -- (0,-2mm);
%
\node [tbox,above]  at (-2.4,0) {DAY (DM)};
\node [tbox,above]  at ( 2.4,0) {NIGHT (CM)};
%
\node [bbox,below right] at (-5,0) {xx xx xx xxx xxx xxx xxx\\ 
                                    yy yy yyy yyy yyyy\\
                                    zzzzz zz zzzz z z zzz};
\node [bbox,below right] at (0,0) {xx xx xx xxx xxx xxx xxx\\
                                    yy yy yyy yyy yyyy\\
                                    zzzzz zz zzzz z z zzz};
\tikzset{>=stealth}
\draw [very thick, <-]  (-5.5,0mm) -- (-5.5, -10mm);
\draw [very thick, <-]  (-6.2,0mm) -- (-6.2, 10mm);
\node [bbox,below right] at (-5.8,-1) {$\eta$};
\node [bbox,above right] at (-6.5,1) {$\mu$};            
\end{tikzpicture}
\end{frame}

enter image description here

1
  • this works, but better approach is as I show in edited answer ...
    – Zarko
    Commented May 20, 2017 at 23:24
0

Another easy solution with pstricks+auto-pst-pdf (to compile with pdflatex):

\documentclass[border =3pt]{standalone}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern
\usepackage{pst-node, auto-pst-pdf}

    \begin{document}

   \begin{pspicture}
\psset{unit=5, tbarsize =2ex, dotsep=1.5pt, shortput=nab}
\pnodes(0,0){B}(1,1ex){I}(1,-1ex){J}(1,0){K}(2,0){E}
\ncline{|-|}{B}{E}
\psset{linestyle=dotted}
\ncline{K}{I}\ncline{K}{J}
\nput[labelsep=0.75em]{-45}{B}{\footnotesize\parbox{4cm}{\small$ σ $ matches are formed. \\ Sellers produce $ q $. \\ Buyers transfer $ d . $}}
\nput[labelsep=0.75em]{-45}{K}{\parbox{4.2cm}{\small Agents trade money for goods at the competitive price $ \phi $. \\ Agents split apart. }}
\psset{linestyle=none}
\sffamily\bfseries
\ncline{B}{K}^{\Rnode{D}{DAY (DM)}}\nput[labelsep=1.5cm]{180}{D}{\normalfont\begin{tabular}{r}Some action $ \rightarrow $ \\Some other action $ \rightarrow $\end{tabular}}
\ncline{K}{E}^{NIGHT (CM)}
\end{pspicture}

    \end{document} 

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .