我需要对曲线、切线和 x 轴所围成的区域进行着色。你能帮忙吗?
\begin{tikzpicture}[scale=1.442515197749737655215]
\draw[line width=1.42pt, ,smooth,samples=1300,domain=-.61851:6.92614618] plot(\x,{\x- ln(1+\x*\x) });
\draw[-> ] (-.8,0)--(7.2469,0) node[right]{$x$};
\draw[-> ] (0,-1.6)--(0,3.02914275) node[above]{$y$};
\draw[dashed](1,0)--(1,.304);
\draw[fill=red](1,0.306852819440054690582767878541823431924499865639744745879) circle(2.05pt);
\draw(1,-.341624) node {1};
\draw(5,-.341624) node {5};
\draw(-.7314205,.307061)node {$1-\ln 2$};
\draw[dashed](1,0)--(1,0.3044);
\draw[fill=red, dashed, very thin](1,0.306852819440054690582767878541823431924499865639744745879) --(0, .306852819440054690582767878541823431924);
\draw(2.105314205,.98307061)node {$y=x-\ln(x^2+1)$};
\draw[line width=.482pt, ,smooth,samples=1300,color=red, domain=-.61851:6.414618] plot(\x,{0.61538*\x-1.335});
\draw[fill=red](1,0.306852819440054690582767878541823431924499865639744745879) circle(1.5pt);
\draw[fill=red](5,1.74119 ) circle(2.05pt);
\draw[dashed, thin](5,0)--(5,1.74173044);
\draw[fill=red, dashed, very thin](5,1.749) --(0, 1.749);
\draw(-.7314205,1.74119)node {$1.7419$};
\end{tikzpicture}
答案1
由于您使用了大量样本,基于 pgfplots fillbetween 库的解决方案需要很长时间才能编译。因此,我提出了一种不同的方法。(尽管如此,我还是将直切线的样本数量减少到 2,并删除了平滑选项。)
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}[scale=1.442515197749737655215]
\draw[line width=1.42pt] plot[smooth,samples=131,domain=-.61851:6.92614618] (\x,{\x- ln(1+\x*\x) });
\draw[->] (-.8,0)--(7.2469,0) node[right]{$x$};
\draw[-> ] (0,-1.6)--(0,3.02914275) node[above]{$y$};
\draw[dashed](1,0)--(1,.304);
\draw[fill=red](1,0.306852819440054690582767878541823431924499865639744745879) circle(2.05pt);
\draw(1,-.341624) node {1};
\draw(5,-.341624) node {5};
\draw(-.7314205,.307061)node {$1-\ln 2$};
\draw[dashed](1,0)--(1,0.3044);
\draw[fill=red, dashed, very thin](1,0.306852819440054690582767878541823431924499865639744745879) --(0, .306852819440054690582767878541823431924);
\draw(2.105314205,.98307061)node {$y=x-\ln(x^2+1)$};
\draw[line width=.482pt,color=red] plot
[smooth,samples=2, domain=-.61851:6.414618] (\x,{0.61538*\x-1.335});
\draw[fill=red](1,0.306852819440054690582767878541823431924499865639744745879) circle(1.5pt);
\draw[fill=red](5,1.74119 ) coordinate (aux2) circle(2.05pt);
\draw[dashed, thin](5,0)--(5,1.74173044);
\draw[fill=red, dashed, very thin](5,1.749) --(0, 1.749);
\draw(-.7314205,1.74119)node {$1.7419$};
\begin{scope}[on background layer]
\clip plot[smooth,samples=131,domain=-.61851:6.92614618] (\x,{\x- ln(1+\x*\x) })
-- (6,0) -- (0,0);
\fill[blue!20] (0,0) -- (1.335/0.61538,0) --(aux2) -- (0,0 |-aux2) ;
\end{scope}
\end{tikzpicture}
\end{document}
请注意,如果您使用 pgfplots 执行此操作并使用其 fillbetween 库,效果会更好。