3
\begin{figure}[H]
\begin{center}
\begin{tikzpicture}
\begin{axis}[xticklabels={},yticklabels={},axis x line=center, axis y 
line=center, xlabel={$x$}, ylabel={$y$}, xlabel style={right}, ylabel style= 
{above},ticks=none]
\addplot[color=brown,domain=-0.1:1.1,samples=100]{(2*x-1)^4};
\addplot[domain=7/8:1.1,samples=100]{8*x-7};
\end{axis}
\node [] at (3.4,0.2) {$P$};
\end{tikzpicture}
\caption{Graph of $y = (2x-1)^4$ (brown) and the tangent function (black) at 
the point $(1,1)$.}
\end{center}
\end{figure}

Hi there I'm not too sure how to shade the region between the tangent function and the curve. Some help would be awesome!!!

  • 3
    Welcome to TeX.SE! Off-topic: don't use center environment within figure, use \centering, see here: tex.stackexchange.com/questions/23650/… – CarLaTeX Nov 28 '18 at 6:25
  • 2
    Welcome to TeX.SX!! Rather than posting code fragments it is better to give a full minimal working example. Currently we have to guess what packages etc you are using and this makes it really hard to help you. A MWE should start with a \documentclass command, have a minimal preamble and then \begin{document}...\end{document}. The code should compile and be as small as possible to demonstrate your problem. – Andrew Nov 28 '18 at 6:26
2

Welcome to TeX.SE! One way is to use fillbetween.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usepgfplotslibrary{fillbetween}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xticklabels={},yticklabels={},axis x line=center, axis y 
line=center, xlabel={$x$}, ylabel={$y$}, xlabel style={right}, ylabel style= 
{above},ticks=none]
\addplot[color=brown,domain=-0.1:1.1,samples=100,name path=curve]{(2*x-1)^4};
\addplot[domain=7/8:1.1,samples=101,name path=tangent]{8*x-7+0.01};
\draw[name path=axis] (0,0) -- (7/8,0);
\node [anchor=south] at (0.5,0) {$P$};
\end{axis}
\path [name path=aux1,%draw=blue,%->,fill=orange,
intersection segments={of=curve and axis,
    sequence={R3[reverse]--L3}}];
\begin{scope}[on background layer]      
 \path [fill=orange,
 intersection segments={of=aux1 and tangent,
     sequence={L1--R1}}];
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

But in this case you can certainly do the fills without fillbetween.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\usetikzlibrary{backgrounds}
\begin{document}
\begin{tikzpicture}
\begin{axis}[xticklabels={},yticklabels={},axis x line=center, axis y 
line=center, xlabel={$x$}, ylabel={$y$}, xlabel style={right}, ylabel style= 
{above},ticks=none]
\addplot[color=brown,domain=-0.1:1.1,samples=101]{(2*x-1)^4};
\addplot[domain=7/8:1.1,samples=2]{8*x-7};
\node [anchor=south] at (0.5,0) {$P$};
\begin{scope}[on background layer]      
 \fill[orange] plot[variable=\x,domain=0.5:1.1,samples=51] (\x,{(2*\x-1)^4})
 -- (1.1,{8*1.1-7})-- (7/8,0);
\end{scope}
\end{axis}
\end{tikzpicture}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.