我很感激有人能帮我创建上面的图表。我取得了一些成功,但仍在努力为图表命名(不在议程中)、交点以及在 x 轴和 y 轴上标记交点值。
\documentclass{article}
\usepackage{pgfplots}
\pgfplotsset{ticks=none}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
%grid = major,
axis x line=center,
axis y line=center,
xlabel={$k_t$},
ylabel={$f(k_t)$},
xlabel style={below right},
ylabel style={above left},
xmin=-1,
xmax=12,
ymin=-1,
ymax=5]
\addplot+[color=green,mark=none,samples=200,domain=0:10,smooth,thick] {sqrt(1*x)} node[below,pos=1,color=black] {$f(k_t)$};
\addplot+[color=black,mark=none,samples=200,domain=0:10,smooth,thick] {2/3*sqrt(1*x)} node[below,pos=1,color=black] {$s f(k_t)$};
\addplot+[color=red,mark=none,samples=200,domain=0:10,smooth,thick] {2/5*x} node[above,pos=1,color=black] {$\delta k_t$};
\end{axis}
\end{tikzpicture}
\end{document}
好的,我已经重新修改了它并且已经更加接近了:
仍然希望得到有关轴上交叉点和标记的输入。
答案1
PSTricks 解决方案:
\documentclass{article}
\usepackage{pst-plot}
% constants
\def\xA{2/3}
\def\xB{1}
\def\xC{2/5}
\def\xEnd{9.8}
% intersection point, $k^{\ast}$
\def\point{(\xA)^2/(\xC)^2}
% functions
\def\fA(#1){(\xA)*sqrt(#1)}
\def\fB(#1){(\xB)*sqrt(#1)}
\def\fC(#1){(\xC)*(#1)}
\psset{
algebraic,
plotstyle = curve,
plotpoints = 500
}
\begin{document}
\begin{pspicture}%
(-0.5,-0.5)%
(\fpeval{\xEnd+1.15},\fpeval{max(\fA(\xEnd),\fB(\xEnd),\fC(\xEnd))+0.55})
\pnodes(\fpeval{\point},0){A}%
(\fpeval{\point},\fpeval{\fB(\point)}){B}%
(0,\fpeval{\fB(\point)}){C}
\psaxes[labels = none]{->}%
(0,0)(-0.5,-0.5)(\fpeval{\xEnd+0.7},\fpeval{\fC(\xEnd)+0.55})
[$k_{t}$,135][$f(k_{t})$,315]
\psplot[linecolor = black]{0}{\xEnd}{\fA(x)}
\uput[0](\xEnd,\fpeval{\fA(\xEnd)}){$sf(k_{t})$}
\psplot[linecolor = green!70!black]{0}{\xEnd}{\fB(x)}
\uput[0](\xEnd,\fpeval{\fB(\xEnd)}){$f(k_{t})$}
\psplot[linecolor = red!70!black]{0}{\xEnd}{\fC(x)}
\uput[0](\xEnd,\fpeval{\fC(\xEnd)}){$\delta k_{t}$}
\psline[linestyle = dashed](A)(B)(C)
\psdots[dotsize = 3pt 2, dotstyle = o, fillcolor = blue!60](A)(B)(C)
\psdot(\fpeval{\point},\fpeval{\fC(\point)})
\uput[270](A){$k^{\ast}$}
\uput[180](C){$y^{\ast}$}
\end{pspicture}
\end{document}
您所要做的就是改变常量的值,绘图就会自动调整。
答案2
您已经加载了intersections
库,但只是没有使用它。这里有一种可能的方法来实现所需的结果。有关详细信息,请查看代码中的注释。
% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{intersections}
% use this `compat' level or higher so that TikZ coordinates don't have to be prefixed
% with `axis cs:'
\pgfplotsset{compat=1.11}
\begin{document}
\begin{tikzpicture}[
% define a style for the dots
dot/.style={
draw=black,
fill=blue!90,
circle,
minimum size=3pt,
inner sep=0pt,
solid,
},
]
\begin{axis}[
xmin=-1,
xmax=12,
ymin=-0.5,
ymax=5,
axis lines=center,
ticks=none,
xlabel={$k_t$},
ylabel={$f(k_t)$},
xlabel style={below right},
ylabel style={above left},
% (moved common `addplot' options here)
smooth,
domain=0:10,
samples=101,
no markers,
]
% to use the `intersections' library you have to give a `name path' to path that
% should be used for intersection calculations
\addplot+ [green,thick,name path=sqrt] {sqrt(x)}
node [below,pos=1,color=black] {$f(k_t)$}
;
\addplot+ [black,thick,name path=mod sqrt] {2/3*sqrt(x)}
node [below,pos=1,color=black] {$s f(k_t)$}
;
\addplot+ [red,thick,name path=line,samples=2] {2/5*x}
node [above,pos=1,black] {$\delta k_t$}
;
% find the intersection of the modified sqrt function and the straight line,
% draw a circle on it and store the coordinate
% (here we have to use the second found intersection point, the first one is at (0,0))
\fill [name intersections={of=mod sqrt and line}] (intersection-2) circle (1.5pt)
coordinate (a)
;
% draw an invisible vertical path at the x coordinate of the found intersection point
\path [name path=vertical line]
(a |- 0,\pgfkeysvalueof{/pgfplots/ymin}) -- (a |- 0,\pgfkeysvalueof{/pgfplots/ymax});
% now find the other intersection point with the sqrt function and again store the
% the found coordinate
\path [name intersections={of=sqrt and vertical line}] (intersection-1) circle
coordinate (b)
;
% draw the dots (using the above defined style) and labels
\draw [dashed]
(b -| 0,0) node [dot,label=left:$y^*$] {}
-- (b) node [dot] {}
-- (b |- 0,0) node [dot,label=below:$k^*$] {}
;
\end{axis}
\end{tikzpicture}
\end{document}
答案3
纯钛钾Z解决方案:
\documentclass[tikz, border=5pt]{standalone}
\usetikzlibrary{arrows.meta, intersections}
\begin{document}
\begin{tikzpicture}[yscale=2,
> = Stealth,
dot/.style = {circle, draw=black, solid,
fill=#1, % default blue!50
minimum size=3pt, inner sep=0pt,
node contents={}},
dot/.default = blue!50,
domain=0:5, samples=100,
]
% axis
\draw[->] (-0.6,0) -- (6,0.0) node [below left] {$k_t$};
\draw[->] (0,-0.2) -- (0,2.5) node [below left] {$f(k_t)$};
\coordinate (O) at (0,0);
% curves
\draw[green,thick,name path=sqrt green] plot (\x, {sqrt(\x)})
node [right,text=black] {$f(k_t)$};
\draw[black,thick,name path=sqrt black] plot (\x, {2*sqrt(\x)/3})
node [right,text=black] {$s f(k_t)$};
\draw[red,thick,name path=line red] plot (\x, 2*\x/5)
node [right,text=black] {$\delta k_t$};
% intersection sqrt black and line red
\path[name intersections={of=line red and sqrt black, by={not used,a}}]
(a) node[dot=black];
% draw an invisible vertical path through coordinate a
\path[name path=vertical line]
(a |- O) -- + (0,2);
% intersection sqrt green and vertical line
\path [name intersections={of=sqrt green and vertical line, by={bb}}]
(bb) node (b) [dot=blue!50];
% draw the dashed lines snd dots on axis
\draw[dashed] (b) -- (b -| O) node [dot,label=left:$y^*$]
(b) -- (b |- O) node [dot,label=below:$k^*$];
\end{tikzpicture}
\end{document}