# How can I 3D plot y=4x^2+z^2 using Pgfplots?

I am trying to 3D plot y=4x^2+z^2 using Pgftools but I'm unable to use z as an independent variable in the function.

\begin{tikzpicture}[scale=1.5]
\begin{axis}[
grid=major,
3d box=complete,
enlargelimits=false,
colormap/cool,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zlabel style = {sloped like x axis}
]
\addplot3 [
surf,
shader=faceted,
samples=20,
] {x^2+z^2};
\end{axis}
\end{tikzpicture}

• Welcome to TeX.SX! Please help us help you by making your code snippet compilable (a MWE). – TeXnician Feb 27 at 17:11
• x and y are just placeholders. You can add a parametric plot. – user121799 Feb 27 at 17:12

## 1 Answer

x and y are just placeholders. You can add a parametric plot.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.16}
\begin{document}
\begin{tikzpicture}[scale=1.5]
\begin{axis}[
grid=major,
3d box=complete,
enlargelimits=false,
colormap/cool,
xlabel=$x$,
ylabel=$y$,
zlabel=$z$,
zlabel style = {sloped like x axis}
]
\addplot3 [
surf,
shader=faceted,
samples=20,
] ({x},{4*x^2+y^2},{y});
\end{axis}
\end{tikzpicture}
\end{document} 