[Tex/LaTex] How to fill an area with fading color

fillbetweentikz-styles

I want to fill an area on a x–y plane with fading color, but have no idea how to do it. I know how to fill shapes with color, but not how to do it when the area is not a well defined shape.

Let me be more specific:
I drew a rough sketch of the implicit function y^2-x^2=a^2:

\documentclass{article}

\usepackage{tikz}

\begin{document}

        \begin{center}
        \begin{tikzpicture}
          \draw[->] (-3,0) -- (3,0) node[right] {$x$};
          \draw[->] (0,-3) -- (0,3) node[above] {$y$};

          \draw (-3,3) parabola bend (0,1.25) (3,3);
          \draw (-3,-3) parabola bend (0,-1.25) (3,-3);
        \end{tikzpicture}
        \end{center}

\end{document}

This produces the following:
enter image description here

Now I want to fill the area that enclosed between these two parabolas with a color that fades away at the right and left edges (to emphasize the fact that the area goes further away to infinity).

Can it be done?

Thanks in advanced!

Best Answer

May be you should use pgfplots which offers fill between facility. But here is a tikz version:

\documentclass{article}

\usepackage{tikz}

\begin{document}

        \begin{center}
        \begin{tikzpicture}
          \draw[thick] (-3,3) parabola bend (0,1.25) (3,3);
          \draw[thick] (-3,-3) parabola bend (0,-1.25) (3,-3);
          \fill[left color = olive!10,right color = olive!10, middle color=olive]
                (-3,3) parabola bend (0,1.25) (3,3) -- (3,-3) parabola bend (0,-1.25) (-3,-3)
                -- (-3,3) -- cycle;
          \draw[->] (-4,0) -- (4,0) node[right] {$x$};
          \draw[->] (0,-3) -- (0,3) node[above] {$y$};
        \end{tikzpicture}
        \end{center}

\end{document}

enter image description here

Using pgfplotsand its fillbetween library, your code would look something like:

\documentclass{article}
\usepackage{pgfplots}
\usepgfplotslibrary{fillbetween}
\pgfplotsset{compat=1.11}

\begin{document}

\begin{center}
\begin{tikzpicture}
\begin{axis}[
  axis lines=middle,
  xtick=\empty,
  ytick=\empty,
  ]
  \addplot[blue,name path=U] {sqrt(3^2+x^2)};
  \addplot[blue,name path=L] {-sqrt(3^2+x^2)};
  \addplot[left color=cyan!05,right color=cyan!05,middle color=cyan!80!black] 
  fill between[of=U and L,soft clip={domain=-5:5},];
\end{axis}
\end{tikzpicture}
\end{center}

\end{document}

And the result:

enter image description here