我非常想使用 Tikz 重现下图。
我尝试了以下方法,但似乎无法使用平滑的线条画曲线。
\begin{document} \begin{center}
\begin{tikzpicture}[scale=0.45]
%Drawing the lines
%Drawing the border
\draw (0,-5) -- (0,10) -- (18,10) -- (18,-5) -- (0,-5);
\draw (0,10);
% curves
\draw [red, thick] plot [smooth, tension=0.15] coordinates {(0,-5) (3.5,-1) (4.5,0) (5, 2.5)};
\end{tikzpicture}
\end{document}
该功能应如下所示:
答案1
你想要 Ti钾Z,对吧?(我的意思是没有 pgfplots。)所以我们开始吧。
\documentclass[tikz,border=5pt]{standalone}
\begin{document}
\begin{tikzpicture}[scale=2]
\foreach \a/\Col in {0.25/blue,0.5/red,1/orange,2/purple,4/black}
{
\draw[\Col] plot[domain=0:4,variable=\x,samples=90] ({\x},{4*(\a*\x^\a)/(\a + \a*\x^\a)});
}
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,2) node[left](p5){$0.5$} -- (4,2);
\node [left of=p5,rotate=90]{$x_1(b_1/b_2)$};
\end{tikzpicture}
\end{document}
只是为了好玩:pgfplots。Phelype 用这个更快。
\documentclass[tikz,border=2mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.15}
\begin{document}
\tikzset{declare function={f(\x,\y)=(\y*\x^\y)/(\y + \y*\x^\y);}}
\begin{tikzpicture}
\begin{axis}[domain=0:4,ytick={0,0.5,1},xtick={0,1,2,3,4},
xmin=0,ymin=0,xmax=4,ymax=1,mark=none,samples=100]
\foreach \a in {0.25,0.5,1,2,4}
{
\addplot[very thick] {f(x,\a)};
}
\draw[dotted] (1,0) -- (1,1);
\draw[dotted] (0,0.5) -- (4,0.5);
\end{axis}
\end{tikzpicture}
\end{document}
答案2
使用 pgfplots:
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{pgfplots}
\begin{document}
\def\b{1}
\begin{tikzpicture}
\begin{axis}[%
domain=0:4,
samples=200,
xmin=0,
xmax=4,
extra x ticks={1},
extra x tick labels={},
extra tick style={grid=major},
xlabel={$b_1/b_2$},
ymin=0,
ymax=1,
ytick={0,0.5,1},
extra y ticks={0.5},
extra y tick labels={},
extra tick style={grid=major},
ylabel={$x_1(b_1/b_2)$},
]
\foreach \a/\clr in {0.25/DarkOliveGreen,
0.5/NavyBlue,
1/FireBrick,
2/DarkGoldenrod,
4/MediumSeaGreen}{%
\expandafter\addplot\expandafter[\clr,
line width=1pt,
mark=none,
] {\a*((x/\b)^\a)/(\a*((x/\b)^\a) + \a*\b^\a)};
}
\end{axis}
\end{tikzpicture}
\end{document}
哦,太晚了:P