Seite 1 von 1

Schattierung mit TikZ

Verfasst: Mo 24. Mai 2010, 18:19
von chim012
Hallo!

Meine Grafik sieht bisher so aus
\begin{tikzpicture}[domain=-2:2]
\fill[color=gray!30!white] (-1.4,0.2116)--plot(\x,{0.1*\x^3+0.01*\x+0.5})--(1.4, 0.7884)--(1.4,1.696)--plot(\x,{0.1*\x^2+1.5})--(-1.4,1.696)--(-1.4,0.2116);

\draw[->](-2.2,0)--(2.2,0) node[right]{$x$};
\draw[->](0,-0.2)--(0,2.2) node[above]{$f(x)$};
\draw[color=blue]	plot (\x,0.1*\x^2+1.5)							node[right]{$f(x)$};
\draw[color=blue]	plot (\x,0.1*\x^3+0.01*\x+0.5)				node[right]{$g(x)$};
\draw[dashed] (1.4,1.696)--(1.4, 0.7884);
\draw[dashed] (-1.4,0.2116)--(-1.4,1.696);
\coordinate [label=below:$a$] (a) at (-1.4,0);
\coordinate[label=below:$b$] (b) at (1.4,0);

\end{tikzpicture}
ich möchte nun die Schattierung oberhalb des Grafen von f(x) wegkriegen. Habt ihr dazu iwelche ideen? bzw. wisst wie diese überhaupt zu stande kommt?

Liebe Grüße &danke
chim012

Geschlossener Pfad

Verfasst: Mo 24. Mai 2010, 18:53
von localghost
Gewöhne dir bitte an, vollständige Beispiele zu erstellen.

Damit alles funktioniert, brauchst Du einen geschlossen Pfad. In diesem Fall heißt das, den Wertebereich einerseits anzupassen und ihn andererseits für f(x) umzukehren.
\documentclass{minimal}
\usepackage{tikz}

\begin{document}
  \begin{tikzpicture}[domain=-2:2]
    \path[fill=gray!30] (-1.4,0.2116)--plot[domain=-1.4:1.4](\x,{0.1*\x^3+0.01*\x+0.5})--(1.4, 0.7884)--(1.4,1.696)--plot[domain=1.4:-1.4](\x,{0.1*\x^2+1.5})--(-1.4,1.696)--(-1.4,0.2116);

    \draw[->](-2.2,0)--(2.2,0) node[right]{$x$};
    \draw[->](0,-0.2)--(0,2.2) node[above]{$f(x)$};
    \draw[color=blue]   plot (\x,0.1*\x^2+1.5) node[right]{$f(x)$};
    \draw[color=blue]   plot (\x,0.1*\x^3+0.01*\x+0.5) node[right]{$g(x)$};
    \draw[dashed] (1.4,1.696)--(1.4, 0.7884);
    \draw[dashed] (-1.4,0.2116)--(-1.4,1.696);
    \coordinate [label=below:$a$] (a) at (-1.4,0);
    \coordinate[label=below:$b$] (b) at (1.4,0);
  \end{tikzpicture}
\end{document}

MfG
Thorsten