[Tex/LaTex] drawing an economic graph

tikz-pgf

I would like to draw the following curve

enter image description here

I have this code, but I could not edit it; any help!

enter image description here

    \begin{tikzpicture}
\begin{axis}[
domain=0:6*pi,
samples=100,
axis lines*=left,
xtick=\empty, ytick=\empty,
width=13cm, height=8cm
]
\addplot [thick, gray] {x};
\addplot [thick, black] {x + 4*sin(deg(x)) * sin(deg(x/6))^0.5}
node [pos=0.1, anchor=south] {Peak}
node [pos=0.3, anchor=south, sloped] {Expansion}
node [pos=0.49, anchor=south, sloped] {Recession}
;
\end{axis}
\end{tikzpicture}

Best Answer

Here is a minimal working example of a graph with variations:

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[domain=0:6*pi,
                  samples=100,
                  axis lines=center,
                  xtick={0},
                  ytick=\empty,
                  xlabel={$x$},
                  ylabel={$f(x)$},
                  xmin=-0.5,
                  xmax=20,
                  width=13cm,
                  height=8cm]
% Plot of the main function
\addplot [thick, black] {6*sin(deg(x)) * sin(deg(x/6))^0.5};
% Nodes on the x axis
\node[fill=black, circle, draw=black, scale=0.4] (a0) at (pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (a1) at (2.5, -1) {$P_{1}$};
\node[fill=black, circle, draw=black, scale=0.4] (b0) at (2*pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (b1) at (7, -1) {$P_{2}$};
\node[fill=black, circle, draw=black, scale=0.4] (c0) at (3*pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (c1) at (11, -1) {$P_{3}$};
% Nodes on the main function and the axis
\node[fill=black, circle, draw=black, scale=0.4] (a2) at (pi/2, 3) {};
\node[fill=black, circle, draw=black, scale=0.4] (a3) at (pi/2, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (a4) at (pi/2, -1) {$P_{0}$};
% Lines to join the nodes on the function to the axis
\draw[dashed] (a2) -- (a3);
\end{axis}
\end{tikzpicture}

\end{document}

I haven't precisely placed the maximum, but this can be adjusted if you change the position of the nodes.

enter image description here

You can also add some commands to draw the horizontal arrows as per the drawing above.

\documentclass[12pt]{article}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}

\begin{document}

\begin{tikzpicture}
\begin{axis}[domain=0:6*pi,
                  samples=100,
                  axis lines=center,
                  xtick={0},
                  ytick=\empty,
                  xlabel={$x$},
                  ylabel={$f(x)$},
                  xmin=-0.5,
                  xmax=20,
                  width=13cm,
                  height=8cm]
% Plot of the main function
\addplot [thick, black] {6*sin(deg(x)) * sin(deg(x/6))^0.5};
% Nodes on the x axis
\node[fill=black, circle, draw=black, scale=0.4] (a0) at (pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (a1) at (2.5, -1) {$\overline{P_{1}}$};
\node[fill=black, circle, draw=black, scale=0.4] (b0) at (2*pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (b1) at (7, -1) {$\overline{P_{2}}$};
\node[fill=black, circle, draw=black, scale=0.4] (c0) at (3*pi, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (c1) at (11, -1) {$\overline{P_{3}}$};
% Nodes on the main function and the axis
\node[fill=black, circle, draw=black, scale=0.4] (a2) at (pi/2, 3) {};
\node[fill=black, circle, draw=black, scale=0.4] (a3) at (pi/2, 0) {};
\node[fill=white, circle, draw=none, scale=0.75] (a4) at (pi/2, -1) {$\overline{P_{0}}$};
% Lines to join the nodes on the function to the axis
\draw[dashed] (a2) -- (a3);
% Arrow commands
\draw[->] (pi/2, 1) -- (1.5*pi/2,1);
\end{axis}
\end{tikzpicture}

\end{document}

enter image description here

Hope that makes it clearer.

Romain

Related Question