绘制经济图表

绘制经济图表

我想绘制以下曲线

在此处输入图片描述

我有此代码,但我无法编辑它;有什么帮助吗?

在此处输入图片描述

    \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}

答案1

这是一个具有变化的图表的最小工作示例:

\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}

我没有精确地放置最大值,但是如果您改变节点的位置,则可以进行调整。

在此处输入图片描述

您还可以添加一些命令来按照上面的绘图绘制水平箭头。

\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}

在此处输入图片描述

希望这样说更清楚。

罗曼

答案2

本网站有很多这样的例子。这里还有一个例子。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{intersections,calc}
\begin{document}
\tikzset{dot/.style={blue,circle,fill,scale=0.4}}
  \begin{tikzpicture}[>=latex,scale=1.2,label distance=-2pt]
    \draw [->,name path=x axis] (0,0) -- (9,0) node [right] {$P$};
    \draw [->] (0,-2) -- (0,0) node [left] {$0$} -- (0,3) node[left]{Ex.P.};
      \draw [red,smooth, domain=0:2.5*pi, name path=wave,thick,
      samples=100] plot
      ({\x+0.4},{cos(2*\x r)});
    \fill[blue]  [name intersections={of={wave} and {x axis}, name=x, total=\n}]
    \foreach \X in {1,...,\n} {(x-\X) node[dot,label={-90+cos(\X*180)*45)}:{$\bar
    P_\X$}] {} };
    \foreach \Y/\Z [count=\X] in
    {0.6/{$P_1'$},2/{$P_1''$},2.6/{$P_2'$},3.4/{$P_2''$}}
    {\path[name path=tmp] (\Y,-2) -- (\Y,3);
     \draw[name intersections={of={wave} and {tmp}, by=y-\X}]
     let \p1 = (y-\X) in (y-\X)
     --(\Y,0) node[blue,yshift={-1*sign(\y1)*2.5mm}] {\Z};
     \ifnum\X=1
     \draw[->] ($(\Y,0)!0.5!(y-\X)$) -- ++ (0.2,0);
     \else
     \ifnum\X=4
     \draw[->] ($(\Y,0)!0.5!(y-\X)$) -- ++ (0.2,0);
     \else
     \draw[->] ($(\Y,0)!0.5!(y-\X)$) -- ++ (-0.2,0);
     \fi
     \fi
     }
  \end{tikzpicture}
\end{document}

在此处输入图片描述

相关内容