在 Tikz 中冲刺函数

在 Tikz 中冲刺函数

如何在 Tikz 中用函数定义的特定线条划线?例如,如何只在下图中划黑线?

\begin{minipage}{0.48\textwidth}
\begin{tikzpicture}[scale=1.4]
\foreach \a/\Col in {0.5/green,1.2/red, 1/black}
{
\draw[\Col] plot[domain=0:4,variable=\x,samples=90] ({\x},{5.7*\x*(\a*\x^\a)/(1+\x^\a)^2});
}
\foreach \a/\Col in {3/cyan,0.02/magenta, 1/black}
{
\draw[\Col] plot[domain=0:4,variable=\x,samples=90] ({\x},{5.7*(\a*\x^2)/(1+\a*\x)^2});
}
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,1.1) node[left]{$0.5$} -- (4,1.1);
\node at (3.6,-.2) {$v_i$};
\node at (-.2,3.5) [rotate=90] {$b_i$};
\end{tikzpicture}

在此处输入图片描述

答案1

您可以执行与颜色完全相同的操作。

\documentclass[border=5mm]{standalone}
\usepackage{pgfplotstable}
\begin{document}
\begin{tikzpicture}[scale=1.4]
\foreach \a/\Col/\dashing in {0.5/green,1.2/red, 1/black/dashed}
{
\draw[\Col,\dashing] plot[domain=0:4,variable=\x,samples=90] ({\x},{5.7*\x*(\a*\x^\a)/(1+\x^\a)^2});
}
\foreach \a/\Col/\dashing in {3/cyan,0.02/magenta, 1/black/dashed}
{
\draw[\Col,\dashing] plot[domain=0:4,variable=\x,samples=90] ({\x},{5.7*(\a*\x^2)/(1+\a*\x)^2});
}
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,1.1) node[left]{$0.5$} -- (4,1.1);
\node at (3.6,-.2) {$v_i$};
\node at (-.2,3.5) [rotate=90] {$b_i$};
\end{tikzpicture}
\end{document}

答案2

\a对于= 1,黑色曲线的两个函数是相同的。列表1/black中的一个函数\foreach可以删除。另一个函数可以移出以\foreach应用不同的线条样式:

\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}[scale=1.4]
\foreach \a/\Col in {0.5/green,1.2/red}
{
  \draw[\Col] plot[domain=0:4,variable=\x,samples=90]
    ({\x},{5.7*\x*(\a*\x^\a)/(1+\x^\a)^2});
}
\foreach \a/\Col in {3/cyan,0.02/magenta}
{
  \draw[\Col] plot[domain=0:4,variable=\x,samples=90]
    ({\x},{5.7*(\a*\x^2)/(1+\a*\x)^2});
}
\draw[dashed] plot[domain=0:4,variable=\x,samples=90]
  ({\x},{5.7*(\x^2)/(1+\x)^2});
\draw (0,0) rectangle (4,4);
\draw [dotted] (1,0) node[below]{$1$} -- (1,4);
\draw [dotted] (0,1.1) node[left]{$0.5$} -- (4,1.1);
\node at (3.6,-.2) {$v_i$};
\node at (-.2,3.5) [rotate=90] {$b_i$};
\end{tikzpicture}
\end{document}

结果

相关内容