1

I use the following code

\documentclass{beamer}
\beamertemplatenavigationsymbolsempty
\usepackage{verbatim}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{tkz-fct}
\usetikzlibrary{arrows, arrows.meta, positioning, calc, intersections, decorations.pathreplacing, decorations.pathmorphing, decorations.markings, shapes, shapes.misc, shapes.symbols, shapes.geometric, patterns, backgrounds, fadings, trees, shadows}
\begin{document}
\tikzset{pics/.cd,
curvea/.style n args={2}{code={
\node [red] at (#1,#2) (begin){}
([shift={(-90.:1.4cm)}]begin.center) node (beginclip){}
([shift={(0.:.2cm)}]begin.center) node (beginr){}
([shift={(30:4.cm)}]beginr.center) node (midtop){}
([shift={(-30:4.cm)}]midtop.center) node (end){}
([shift={(0.:.2cm)}]end.center) node (endr){}
([shift={(-90.:1cm)}]endr.center) node (endrclip){}
([shift={(0:.5cm)}]beginr.center) node (arrowl){}
([shift={(180:.5cm)}]end.center) node (arrowr){}
([shift={(180:2.46cm)}]midtop.center) node (midtopll){}
([shift={(0:2.46cm)}]midtop.center) node (midtoprr){}
([shift={(180:1.46cm)}]midtop.center) node (midtopl){}
([shift={(0:1.46cm)}]midtop.center) node (midtopr){}
;
}}}
\begin{frame}[t]
\frametitle{variation}
\begin{tikzpicture}[scale=.78, transform shape]
% Axis
\draw [thick](0,0) -- (14.5,0);
\draw [thick](0,0) -- (0,6.);
%Curve
\pic at (0,0) {curvea={1.64}{.28}};
\draw[red!40!white, very thick, fill=red!20!white] ([shift={(-170.:1.4cm)}]begin.center) to [out=10, in=-160, looseness=.68] (beginr.center) to [out=20, in=180, looseness=.6] ([shift={(90:2.6cm)}]midtop.center) node (midtopnewr){} to [out=0, in=150, looseness=.6] (end.center) to [out=-20, in=180, looseness=.68] ([shift={(-10.:1.4cm)}]endr.center);
\end{tikzpicture}
\end{frame}
\end{document}

to draw the following graph

enter image description here

How can this code be modified so that the area outside the curve (and not inside it) could be filled, as in the following graph

enter image description here

3

Add the border lines to make the area outside the curve in a closed path.

\begin{tikzpicture}[scale=.78, transform shape]
% Axis
  \draw [thick] (0,0) -- (14.5,0);
  \draw [thick] (0,0) -- (0,6.);
% Curve
  \pic at (0,0) {curvea={1.64}{.28}};
  \draw [red!40!white, very thick, fill=red!20!white] ([shift={(-170.:1.4cm)}]begin.center) to [out=10, in=-160, looseness=.68] (beginr.center) to [out=20, in=180, looseness=.6] ([shift={(90:2.6cm)}]midtop.center) node (midtopnewr){} to [out=0, in=150, looseness=.6] (end.center) to [out=-20, in=180, looseness=.68] ([shift={(-10.:1.4cm)}]endr.center) -- ++(0, 4.85) -- ++(-10, 0) -- cycle;
\end{tikzpicture}

enter image description here

1
  • Thank you very much. – Hany Aug 8 '20 at 6:55
2

draw a filled rectangle before the curve:

\begin{tikzpicture}[scale=.78, transform shape]
% Axis
\draw [thick](0,0) -- (14.5,0);
\draw [thick](0,0) -- (0,6.);
%Curve
\pic at (0,0) {curvea={1.64}{.28}};
\filldraw[green] (0.1,0.05) rectangle (10.8,4.9);
\draw[red!40!white, very thick, fill=white] ([shift={(-170.:1.4cm)}]begin.center) to [out=10, in=-160, looseness=.68] (beginr.center) to [out=20, in=180, looseness=.6] ([shift={(90:2.6cm)}]midtop.center) node (midtopnewr){} to [out=0, in=150, looseness=.6] (end.center) to [out=-20, in=180, looseness=.68] ([shift={(-10.:1.4cm)}]endr.center);

\end{tikzpicture}

enter image description here

1
  • Thank you very much. – Hany Aug 8 '20 at 6:55

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.