1

hola quiero que el área bajo la curva y la recta sea con un solo fill between (entre ambas funciones) como hago?

per Google translate : Hi I want to fill the area under the curve and the line (between both functions) with a single colour. How do I do that?

enter image description here

no marks,
]
\addplot+[smooth,blue,samples=201,smooth,domain=-3:-0.01,name path=A] {sqrt (2*x+6)]}; % actual curve
\addplot+[smooth,black,samples=201,smooth,domain=-3:-0.01,name path=B] {0}; % actual curve
\addplot+[blue!2] fill between[of=A and B,soft clip={domain=-5:5}]; % filling

\addplot+[smooth,blue,samples=201,smooth,domain=-3:1,name path=A] {0}; % actual curve
\addplot+[smooth,blue,samples=201,smooth,domain=-3:10,name path=B] {-sqrt (2*x+6)]}; % actual curve
\addplot+[green!6] fill between[of=A and B,soft clip={domain=-5:-1}]; % filling

\addplot+[smooth,black,samples=201,smooth,domain=-3:1,name path=A] {0}; % actual curve
\addplot+[smooth,blue,samples=201,smooth,domain=-3:10,name path=B] {x-1}; % actual curve
\addplot+[magenta!6] fill between[of=A and B,soft clip={domain=-1:-0.01}]; % filling

\addplot+[smooth,black,samples=201,smooth,domain=-3:1,name path=A] {0}; % actual curve
\addplot+[smooth,blue,samples=201,smooth,domain=-3:10,name path=B] {x-1}; % actual curve
\addplot+[brown!6] fill between[of=A and B,soft clip={domain=0.01:1}]; % filling



\addplot+[smooth,blue,samples=201,smooth,domain=0.01:1,name path=A] {sqrt (2*x+6)]}; % actual curve
\addplot+[smooth,black,samples=201,smooth,domain=0.01:1,name path=B] {0}; % actual curve
\addplot+[blue!6] fill between[of=A and B,soft clip={domain=-2:1}]; % filling

\addplot+[smooth,blue,samples=201,smooth,domain=1:10,name path=A] {sqrt (2*x+6)]}; % actual curve
\addplot+[smooth,blue,samples=201,smooth,domain=0:7,name path=B] {x-1}; % actual curve
\addplot+[yellow!6] fill between[of=A and B,soft clip={domain=1:5}]; % filling



\addplot+[smooth,red,samples=201,smooth,domain=-5:10,name path=B] {x-1}; % actual curve

\legend{$\displaystyle  y=\sqrt{2\,x+6} $,$\displaystyle y=x-1$,$\displaystyle y_2=4\,\,\,\,\,y_1=-2\,\,\,\,\,A_t=18$}
\end{axis}
\end{tikzpicture}
\end{center}
3
  • 5
    Hi, welcome. This is an English-language website, could you translate your post into English? – Torbjørn T. Feb 13 '17 at 12:49
  • 2
    and when you are at it you can also complete your code that it is a full minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}. – Stefan Pinnow Feb 13 '17 at 13:11
  • You keep filling with different colors. Why not just fill with the same color every time? – Teepeemm Feb 13 '17 at 18:54
5

Because the question is not quite clear so far, here a reduced example of your code just showing how to fill the closed area between the root curve and the straight line.

For details on how it works, please have a look at the comments in the code.

% used PGFPlots v1.14
\documentclass[border=5pt]{standalone}
\usepackage{pgfplots}
    \usepgfplotslibrary{fillbetween}
\begin{document}
    \begin{tikzpicture}
        \begin{axis}[
            xmin=-4,    xmax=6,
            ymin=-5,    ymax=6,
            axis lines=middle,
            axis equal image=true,
            axis on top,
            no markers,
            smooth,
            domain=-6:6,
        ]

%            % simplest is reformulate the root function to a parabola ...
%            \addplot+ [name path=curve] {sqrt(2*x+6)};
            % ... and draw it as parametric plot
            \addplot+ [name path=curve] (0.5*x^2-3, x);

            \addplot+ [name path=line]  {x-1};

            % then you only want to fill the closed segment which number 1
            % (the counting starts from 0)
            % to to so you don't want to fill anything else
            \addplot [fill=none] fill between [
                of=curve and line,
                % to be able to apply styles to each segment
                split,
                % then provide the style to fill the named segment
                every segment no 1/.style={
                    fill=green!50,
                },
            ];
        \end{axis}
    \end{tikzpicture}
\end{document}

image showing the result of above code

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.