Playing with representation of orbitals

Two lobes:

With two lobes

%!TEX lualatex
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{trig format plots=rad, compat=1.18}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[colormap/violet, view={40}{30}, axis equal, hide axis]
    \addplot3[
      surf,
      domain     = 0:pi,
      domain y   = 0:2*pi,
      samples    = 120,
      samples y  = 120,
      z buffer   = sort,
      ultra thin
    ] (
      {sin(x)*cos(y)*(sqrt(3/(4*pi))*sin(x)*cos(y))^2},
      {sin(x)*sin(y)*(sqrt(3/(4*pi))*sin(x)*cos(y))^2},
      {cos(x)*(sqrt(3/(4*pi))*sin(x)*cos(y))^2}
    );
  \end{axis}
\end{tikzpicture}
\end{document}

Cut to a single lobe:

Cut to a single lobe

%!TEX lualatex
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{trig format plots=rad, compat=1.18}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[colormap/violet, view={40}{30}, axis equal, hide axis]
    \addplot3[
      surf,
      domain     = 0:pi,
      domain y   = 0:2*pi,
      samples    = 120,
      samples y  = 120,
      z buffer   = sort,
      ultra thin
    ] (
      { sin(x)*cos(y) * ( sqrt(3/(4*pi)) * max(0, cos(x)) )^2 },
      { sin(x)*sin(y) * ( sqrt(3/(4*pi)) * max(0, cos(x)) )^2 },
      { cos(x)        * ( sqrt(3/(4*pi)) * max(0, cos(x)) )^2 }
    );
  \end{axis}
\end{tikzpicture}
\end{document}

Four lobes:

With four lobes
Screenshot
%!TEX lualatex
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{trig format plots=rad, compat=1.18}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[colormap/violet, view={60}{70}, hide axis]
    \addplot3[
      surf,
      domain     = 0:pi,
      domain y   = 0:2*pi,
      samples    = 120,
      samples y  = 120,
      z buffer   = sort,
      ultra thin
    ] (
      {   sin(x)*cos(y) * (sqrt(15/(16*pi))
        * sin(x)^2 * cos(2*y))^2 },
      {   sin(x)*sin(y) * (sqrt(15/(16*pi))
        * sin(x)^2 * cos(2*y))^2 },
      {   cos(x)        * (sqrt(15/(16*pi))
        * sin(x)^2 * cos(2*y))^2 }
    );
  \end{axis}
\end{tikzpicture}
\end{document}

Six lobes:

With six lobes
Screenshot
%!TEX lualatex
\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{trig format plots=rad, compat=1.18}
\usepgfplotslibrary{colormaps}
\begin{document}
\begin{tikzpicture}
  \begin{axis}[colormap/violet, view={40}{30}, axis equal, hide axis]
    \addplot3[
      surf,
      domain     = 0:pi,
      domain y   = 0:2*pi,
      samples    = 120,
      samples y  = 120,
      z buffer   = sort,
      ultra thin
    ] (
  { sin(x)*cos(y) * ( cos(x)^4 + (sin(x)^4)*(cos(2*y)^2) ) },
  { sin(x)*sin(y) * ( cos(x)^4 + (sin(x)^4)*(cos(2*y)^2) ) },
  { cos(x)        * ( cos(x)^4 + (sin(x)^4)*(cos(2*y)^2) ) }
);
  \end{axis}
\end{tikzpicture}
\end{document}

See also: Original Source by Stefan Kottwitz

Note: The copyright belongs to the blog author and the blog. For the license, please see the linked original source blog.