我想绘制一个简化的米氏动力学(单函数)来将其与线性函数进行比较。
最小工作示例(MWE):
\documentclass{standalone}
\usepackage{pgfplots}
\usepackage{amsmath}
\pgfplotsset{compat=1.14, /pgf/declare function={f1(\x)=ln(x);}}% <- This is the exponential function which needs to be optimized
\begin{document}
\begin{tikzpicture}
\begin{axis}[
ymin = 0,
xmin = 0,
xmax = 1,
ymax = 0.9,
axis x line = bottom,
axis y line = left,
]
% \addplot[no marks, samples=100, draw=blue] {f1(x)};% This is the exponential graph based on the function
\addplot[no marks, samples=100, draw=black, thick] coordinates{(0,0) (0.2020725942,0.35)};%
\addplot[no marks, samples=100, draw=black, thick] (0.2020725942,0.35) to [out=60,in=180] (0.8,0.7) to [out=0,in=0] (1,0.7);%
\draw[draw=black, dashed] (0,0.7) -- node[above] {\(y_{\text{tot}}\)} ++(0.8,0.0);%
\draw[draw=black, dashed] (0,0.35) -- node[above] {\(\frac{y_{\text{tot}}}{2}\)} ++(0.2020725942,0) -- (0.2020725942,-0.35);%
\end{axis}
\end{tikzpicture}
\end{document}
结果截图:
问题说明:
我怎样才能用指数图替换当前图?
指数图的起点:
- 起点:x = 0.2020725942,y = 0.35,角度 = 60°,
- 终点:y = ~ 0.7(当然,e 函数的终点是这里)
一旦我用指数函数激活图形,我的整个图表就会扭曲。如何正确实现基于上限值的指数图?
答案1
一种方法是通过这个(请注意,这使用与您的不同的函数)。你MWE
没有错IMO
。但是,由于域不同,您的最终轴变得混乱。
尽管如此,您可以通过两个指数相加来获得所需的解决方案。
\documentclass{amsart}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{tikz}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
scaled ticks=false,
xmin=0,
xmax=1,
ymin=0,
ymax=1.2,
xlabel=x axis label,
ylabel=y axis label,
axis x line = bottom,
axis y line = left,
]
\addplot[domain=0.2:1.2, samples=1000, red, ultra thick,smooth] {(1-e^(-5*x)-exp(-10*x))*0.7};
\addplot[no marks, samples=100, draw=black, thick] coordinates{(0,0) (0.2020725942,0.35)};%
\draw[draw=black, dashed] (0,0.7) -- node[above] {\(y_{\text{tot}}\)} ++(1,0.0);%
\draw[draw=black, dashed] (0,0.35) -- node[above] {\(\frac{y_{\text{tot}}}{2}\)} ++(0.2020725942,0) -- (0.2020725942,-0.35);%
\end{axis}
\end{tikzpicture}
\end{document}
要得到:
答案2
我找不到这样的函数。这里,具有精确起始角度 (60°) 和终止角度 (180°) 的曲线就足够了。
另外,你为什么不直接在 Ti 中使用 tan 函数钾Z? 0.2020725942 ≈ 0.35 × tan(30°),但如果你输入的话,{.35*tan(30)}
它肯定比 更准确0.2020725942
。
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=8,>=stealth]
\draw[<->] (1,0) -- (0,0) -- (0,.9);
\draw[thick] (0,0) -- ({.35*tan(30)},0.35) coordinate (a);
\draw[thick] (a) to[out=60,in=180] (0.8,0.7) -- (1,0.7);
\foreach \i in {0,0.2,0.4,0.6,0.8} {
\draw (\i,.01) -- (\i,-.01) node[below] {$\i$};
\draw (.01,\i) -- (-.01,\i) node[left] {$\i$};
}
\draw (1,.01) -- (1,-.01) node[below] {$1$};
\draw[dashed] (0.8,0.7) -- (0,0.7) node[midway,above] {$y_\mathrm{tot}$};
\draw[dashed] ({.35*tan(30)},0) -- ({.35*tan(30)},0.35);
\draw[dashed] ({.35*tan(30)},0.35) -- (0,0.35) node[midway,above] {$y_\mathrm{tot}/2$};
\end{tikzpicture}
\end{document}