%24%20%E6%9B%B2%E7%B7%9A%E4%B8%8B%E6%96%B9%E7%9A%84%E9%9D%A2%E7%A9%8D.png)
答案1
為了娛樂! (如果有更多,將更新,:-))
編譯用漸近線或者漸近線 Web 應用程式。
札科的密碼
import graph;
size(10cm,8cm,false);
real f(real x){return x^2;}
path F=graph(f,0,5,350);
picture pic;
fill(pic,box((2,0),(4,25)),orange);
clip(pic,F--(5,0)--cycle);
add(pic);
label("$S$",(3,3));
draw(Label("$a$",BeginPoint),(2,0)--(2,f(2)),dashed);
draw(Label("$a$",BeginPoint),(4,0)--(4,f(4)),dashed);
draw(Label("$f(x)$",Relative(.99),LeftSide),F);
draw(Label("$x$",Relative(.99)),(0,0)--(5,0),Arrow);
draw(Label("$y$",Relative(.99),LeftSide),(0,0)--(0,5^2),Arrow);
CFG的程式碼
unitsize(1cm);
path f=(-0.3,3.7) .. controls (2.3,0.9) and (3.1,3.9) .. (5.1,4)
.. controls (6.5,4.1) and (6.5,3) .. (8.2,2);
picture pic;
fill(pic,box((0.5,0),(6,5)),pink);
draw(pic,(0.5,0)--(0.5,5),dashed);
draw(pic,(6,0)--(6,5),dashed);
clip(pic,f--(8.2,0)--(-0.3,0)--cycle);
add(pic);
label("$S$",(3.2,1.5));
label("$a$",(0.5,0),S);
label("$b$",(6,0),S);
draw(Label("$f(x)$",Relative(.95),LeftSide),f,red+1bp);
draw(Label("$y$",Relative(.99)),(0,-0.5)--(0,6),Arrow);
draw(Label("$x$",Relative(.99),LeftSide),(-0.5,0)--(8.3,0),Arrow);
不是我的!
答案2
有點尷尬但還好:
\documentclass[tikz]{standalone}
\begin{document}
\begin{tikzpicture}
\begin{scope}
\clip (-0.3,3.7) .. controls (2.3,0.9) and (3.1,3.9) .. (5.1,4) .. controls (6.5,4.1) and (6.5,3) .. (8.2,2)--(6,-1)--(-.3,-1)--cycle;
\fill[pink] (0.5,0)node [below=5pt, black] {$a$}--(6,0)node [below=5pt, black] {$b$}--(6,5)--(0.5,5)--(0.5,0)--cycle ;
\draw[thick, red, dashed] (0.5,0)--(0.5,5);
\draw[thick, red, dashed] (6,0)--(6,5);
\node at (3.2,1.5) {$\Huge S$};
\end{scope}
\draw[ultra thick, red] (-0.3,3.7) .. controls (2.3,0.9) and (3.1,3.9) .. (5.1,4) .. controls (6.5,4.1) and (6.5,3) .. (8.2,2)node[black, above=15pt,pos=.9]{$f(x)$};
\draw [thick, ->] (0,-.5)--(0,6) node[left]{$y$};
\draw [thick, ->] (-.5,0)--(8.3,0) node[below]{$x$};
\end{tikzpicture}
\end{document}
輸出:
答案3
和pgfplots
:
\documentclass[margin=3mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\usepgfplotslibrary{fillbetween}
\begin{document}
\begin{tikzpicture}
\begin{axis}[
axis lines=middle,
xlabel=$x$, ylabel=$y$,
xlabel style = {anchor=north east},
ylabel style = {anchor=north east},
xtick=\empty, ytick=\empty,
clip=false
]
\addplot [name path=A,domain=0:5] {x^2} node[left] {$f(x)$};
\path [name path=B]
(\pgfkeysvalueof{/pgfplots/xmin},0) --
(\pgfkeysvalueof{/pgfplots/xmax},0);
\addplot [orange]
fill between [of=A and B,
soft clip={(2,0) rectangle (4,25)},];
\node at (3,3) {$S$};
\draw[dashed] (2,2^2) -- (2,0) node[below] {$a$}
(4,4^2) -- (4,0) node[below] {$b$};
\end{axis}
\end{tikzpicture}
\end{document}
筆記:MWE 基於pgfplots
手冊中的範例,章節5.7 填充之間。