# PGFplots - rotating a cartesian equation around the z axis

My problem is that I would like to create a surface by rotating the function in the range -10 < z < 0 around the z axis to create a kind of pouch-shaped surface.

I've been doing research and this solution would be ideal, apart from the fact that my function is cartesian and not parametric. A trawl of the pgfplots manual has not yielded anything helpful in this respect.

My question is are there any ways to rotate a cartesian rather than polar or parametric equation around an axis, as my function is a bit of a pain to turn into a parametric. If anyone could suggest a parametric function that looks about the same, that would also be great!

Any and all help would be appreciated

As I understand it, we have a function

f(\z) = \z-pow(\z,3)-2


and two parameters, one for the rotation angle with the range [0,360] (call it x in pgfplots terms) and one for the value of \z with the range [-10,0] (call it y in pgfplots terms). The three coordinates of the plot are the coordinates of a circle in the x-y-plane with radius f(y) centred around the z-axis and y as the z-component, i.e.,

( {f(y)*sin(x)}, {f(y)*cos(x)}, y )


\documentclass[border=2pt]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{tikzpicture}%
[declare function={ f(\z) = \z-pow(\z,3)-2; }
]
\begin{axis}
surf,
domain    = 0:360,
y domain  = -10:0,
samples   = 50,
samples y = 20,
]
( {f(y)*sin(x)}, {f(y)*cos(x)}, y );
\end{axis}
\end{tikzpicture}
\end{document}

• that is almost what I'm looking for, but with the graph plotted with respect to different axis. Sorry for any confusion, I've edited the question to make this more clear (I hope) – Utumno Feb 10 '17 at 8:28
• @Utumno Second try; I think that the plot now shows what you want. – gernot Feb 10 '17 at 9:42
• Thanks, that worked! This is my first encounter with 3d parametrics, your answer helped me understand a lot more – Utumno Feb 10 '17 at 10:15