帮助经济图表

帮助经济图表

我是 LaTeX 新手,但我需要绘制这个 2 周期模型。提前谢谢您!

Screenshot

答案1

尝试解读您的扫描确实很麻烦。

\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{decorations.markings,intersections}
\begin{document}
\begin{tikzpicture}[scale=1.44,>=latex,declare
function={f(\x)=0.5*cos(2*deg(\x-0.8))-0.4*\x+pi;}]
 \pgfmathsetmacro{\DeltaX}{(pi/180)*atan(2/(3*pi))/2}
 \draw[thick,latex-latex,name path=axes] (0,5)node[below left]{$t_1$} -- (0,0) coordinate(O) -- (7,0) node[below left]{$t_2$};
 \draw[blue,thick] plot[smooth,samples=30,variable=\x,domain=0:2.2]
 ({\x},{f(\x)}) coordinate(x1);
 \draw[blue,thick] plot[smooth,samples=30,variable=\x,domain=4.5:6.5]
 ({\x},{f(\x)});
 \draw[red,thick,postaction=decorate,decoration={markings,mark=% actually add a mark
      between positions 0.1 and 0.9 step 5pt
      with
      {
        \draw[black,thin] (-2pt,2pt) -- (2pt,-2pt);
      }}] (0.8+\DeltaX,{f(0.8+\DeltaX)}) coordinate (x2) 
      -- (0.8+1.5*pi-\DeltaX,{f(0.8+1.5*pi-\DeltaX)}) coordinate(x3)
      coordinate[pos=-0.5](xm) coordinate[pos=1.5](xp);
 \path[name path=extension] (xm) -- (xp);     
 \draw[red,name intersections={of=axes and extension}]
 (intersection-1) -- (x2) (intersection-2) -- (x3);
 \fill[red]  (x2) circle(1.5pt) (x3) circle(1.5pt);
 \draw[dashed] (O |- x1) node[left]{$\ell_1$} -| (O -|x1) node[below]{$\ell_0$};
 \draw[dashed] (-1,0 |- x2) coordinate(y2a) -| (0,-0.5 -|x2) coordinate(y2b);
 \draw[dashed] (O) -- (0,-1) coordinate (y3);
 \draw[dashed] (-1,0 |- x3) --(O |- x3) node[left,fill=white]{$x_1$} -| (y3-|x3);
 \draw[<->] (y2a) -- (y2a|-x3) node[midway,left]{$y$};
 \draw[<->] (y2b) -- (y2b-|x1) node[midway,below]{$z$};
 \draw[<->] (y3) -- (y3-|x3) node[midway,below]{$x_0$};
 % additional request
 \path (y2a) -- (y2a-|0,0) coordinate[midway] (y2c);
 \draw[<->] (y2c) -- (y2c|-x1) node[midway,fill=white]{$f(z)$};
\end{tikzpicture}
\end{document}

enter image description here

附录

enter image description here

\documentclass[fleqn]{article}
\usepackage{amsmath,amssymb}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,intersections}
\begin{document}
\section*{A short note on a somewhat more systematic construction of such plots}

The function you want to plot seems to have two branches with local maxima. We
are interested in constructing something that resembles that with little effort.
The basic observation is that the plot looks like a superpostion of 
a cosine and some line with constant negative slope, and some part omitted, as
sketched in Figure~\ref{fig:ansatz}.

\begin{figure}[htb]
\centering
\begin{tikzpicture}[declare function={f(\x)=0.5*cos(3*deg(\x-0.8));
g(\x)=0.5*cos(3*deg(\x-0.8))-0.4*\x;}]
\pgfmathsetmacro{\DeltaX}{(pi/180)*atan(2/(3*pi))/3}
\begin{scope}[local bounding box=left]
 \draw[blue] plot[variable=\x,domain=0:1.5*pi,smooth,samples=90] ({\x},{f(\x)});
 \draw[red] (0.8+\DeltaX,{f(0.8+\DeltaX)}) -- (0.8+pi-\DeltaX,{f(0.8+pi-\DeltaX)});
\end{scope} 
\begin{scope}[local bounding box=right,xshift=6cm]
 \draw[blue] plot[variable=\x,domain=0:1.5*pi,smooth,samples=90]
 ({\x},{g(\x)});
 \draw[red] (0.8+\DeltaX,{g(0.8+\DeltaX)}) -- (0.8+pi-\DeltaX,{g(0.8+pi-\DeltaX)});
\end{scope} 
\draw[ultra thick,-latex] (left.south east) -- (left.south east -| right.west);
\end{tikzpicture}
\caption{Motivation of the ansatz.}
\label{fig:ansatz}
\end{figure}

This suggests an ansatz of the form
\begin{equation}\label{eq:ansatz}
 f(x)~=~a\,\cos[b\,(x-x_0)]+c\,x+d\;.
\end{equation} 
The slope of this function is periodic with period $2\pi/b$. The slope of the
point slightly right of the left maximum, i.e.\ at $x=x_1=x_0+\Delta x$, and the
slope of the point slightly left of the right minimum, i.e.\ at
$x=x_2=x_0+\frac{3\pi}{b}-\Delta x$, coincide by construction. $\Delta x$ is
determined by the requirement that 
\[ f'(x_1)~=~-a\,b\,\sin(b\,\Delta x)~\stackrel{!}{=}~
-\frac{2a\,\cos(b\,\Delta x)}{3\pi/b}~=~-2a\,b\,\frac{\cos(b\,\Delta x)}{3\pi}\;,\]
which fixes 
\[
 \Delta x~=~\frac{1}{b}\arctan\left(\frac{2}{3\pi}\right)\;.
\]
With all these preparations one only needs to adjust the parameters in
\eqref{eq:ansatz} to change the appearance of the plot without losing the
features.

\begin{figure}[htb]
\centering
\begin{tikzpicture}[scale=1.44,>=latex,declare
function={f(\x)=0.5*cos(2*deg(\x-0.8))-0.4*\x+pi;}]
 \pgfmathsetmacro{\DeltaX}{(pi/180)*atan(2/(3*pi))/2}
 \draw[thick,latex-latex,name path=axes] (0,5)node[below left]{$t_1$} -- (0,0) coordinate(O) -- (7,0) node[below left]{$t_2$};
 \draw[blue,thick] plot[smooth,samples=30,variable=\x,domain=0:2.2]
 ({\x},{f(\x)}) coordinate(x1);
 \draw[blue,thick] plot[smooth,samples=30,variable=\x,domain=4.5:6.5]
 ({\x},{f(\x)});
 \draw[red,thick,postaction=decorate,decoration={markings,mark=% actually add a mark
      between positions 0.1 and 0.9 step 5pt
      with
      {
        \draw[black,thin] (-2pt,2pt) -- (2pt,-2pt);
      }}] (0.8+\DeltaX,{f(0.8+\DeltaX)}) coordinate (x2) 
      -- (0.8+1.5*pi-\DeltaX,{f(0.8+1.5*pi-\DeltaX)}) coordinate(x3)
      coordinate[pos=-0.5](xm) coordinate[pos=1.5](xp);
 \path[name path=extension] (xm) -- (xp);     
 \draw[red,name intersections={of=axes and extension}]
 (intersection-1) -- (x2) (intersection-2) -- (x3);
 \fill[red]  (x2) circle(1.5pt) (x3) circle(1.5pt);
 \draw[dashed] (O |- x1) node[left]{$\ell_1$} -| (O -|x1) node[below]{$\ell_0$};
 \draw[dashed] (-1,0 |- x2) coordinate(y2a) -| (0,-0.5 -|x2) coordinate(y2b);
 \draw[dashed] (O) -- (0,-1) coordinate (y3);
 \draw[dashed] (-1,0 |- x3) --(O |- x3) node[left,fill=white]{$x_1$} -| (y3-|x3);
 \draw[<->] (y2a) -- (y2a|-x3) node[midway,left]{$y$};
 \draw[<->] (y2b) -- (y2b-|x1) node[midway,below]{$z$};
 \draw[<->] (y3) -- (y3-|x3) node[midway,below]{$x_0$};
\end{tikzpicture}
\caption{Result.}
\label{fig:result}
\end{figure}
\end{document}

enter image description here

相关内容