# TikZ PGF: How to draw 3D graph based on polynomial equation?

Unfortunately the TikZ-manual is a bit complicated to understand about this point.

Assumed we have some kind of squared 3D graph like this one:

Minimum Working Example (MWE):

\documentclass{standalone}
\usepackage{tikz, pgfplots}

\begin{document}

\begin{tikzpicture}
\begin{axis}[samples=20]
\end{axis}
\end{tikzpicture}

\end{document}


Screenshot of the result: 1. How can I replace the current graph with some 4th degree polynomial formula in both directions x and y, e.g. x^4-2*x^2 and y^4-2*y^2
2. How can I set the domain for x- and y-axis from -1 to +1 and the domain for z-axis from 0 to +1?

Just for explanation: The desired picture should visualize flow velocity distribution of pipe flow through porous media (where the flow velocity is highest at the border areas). While in empty pipe flow the velocity reaches its maximum in the center, this is different in porous media what I want to display with the graph.

Typical pipe flow (as 2D model): Typical pipe flow through porous media (as 2D model): Please do not pay attention to the x- and y-shifts. The graph should be centered.

• What precisely do you mean by "in both directions"? You can plot arbitrary functions with e.g.  \addplot3[surf, domain=-2:2] {x^4-2*x^2};.The domains can be set with domain=-1:1 and (if the y domain is different) domain y=-1:1. – user121799 Jan 26 at 21:55

A few things:

1. The relevant manual here is probably the one of pgfplots, not TikZ.
2. You can plot arbitrary functions.
3. You are already setting a domain. If you want to have a different domain for y, use domain y=....
4. You can add zmin and zmax to set the range of the z axis.

These things get illustrated in the MWE.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}

\begin{document}

\begin{tikzpicture}
\begin{axis}[samples=20,zmin=0,zmax=1] 