![以特定方式使用 tikz 绘制包含曲线的独特图形](https://linux22.com/image/461030/%E4%BB%A5%E7%89%B9%E5%AE%9A%E6%96%B9%E5%BC%8F%E4%BD%BF%E7%94%A8%20tikz%20%E7%BB%98%E5%88%B6%E5%8C%85%E5%90%AB%E6%9B%B2%E7%BA%BF%E7%9A%84%E7%8B%AC%E7%89%B9%E5%9B%BE%E5%BD%A2.png)
答案1
plot
您可以使用同一个命令添加点和\draw
。
像这样:
\documentclass[tikz,border=2mm]{standalone}
% example of a function with a parameter \k
\tikzset{declare function={f(\x,\k)=0.5*cos(2*\x r)+\k;}}
\begin{document}
\begin{tikzpicture}
\draw (0,3) |- (4,0) -- (4,3);
\draw[fill=green!20] plot[samples=101,domain=0:4] (\x,{f(\x,2)}) -- (4,0) -| cycle;
\end{tikzpicture}
\begin{tikzpicture}
\draw (0,3) |- (4,0) -- (4,3);
\foreach[count=\ii]\i in {green,orange,yellow}
\draw[fill=\i!20] plot[samples=101,domain=0:4] (\x,{f(\x,2.5-0.5*\ii)}) -- (4,0) -| cycle;
\end{tikzpicture}
\end{document}