Edit and compile if you like:
\documentclass{article}
\usepackage{tikz}
%\usepackage{amsmath,amssymb,amsfonts}
\usepackage{tikz-3dplot}
%\usetikzlibrary{math}
\usepackage{ifthen}
\usepackage[active,tightpage]{preview}
\PreviewEnvironment{tikzpicture}
\setlength\PreviewBorder{1pt}
%
% File name: differential-of-surface-area-spherical-coordinates.tex
% Description:
% A geometric representation of the differential of surface area
% in spherical coordinates is shown.
%
% Date of creation: May, 29th, 2021.
% Date of last modification: October, 9th, 2022.
% Author: Efraín Soto Apolinar.
% https://www.aprendematematicas.org.mx/author/efrain-soto-apolinar/instructing-courses/
% Source: page 122 of the
% Glosario Ilustrado de Matem\'aticas Escolares.
% https://tinyurl.com/5udm2ufy
%
% Terms of use:
% According to TikZ.net
% https://creativecommons.org/licenses/by-nc-sa/4.0/
% Your commitment to the terms of use is greatly appreciated.
%
\begin{document}
%
\begin{center}
\tdplotsetmaincoords{70}{120}
%
\begin{tikzpicture}[tdplot_main_coords]
% Coordinates of the location of the differential of surface area
\pgfmathsetmacro{\x}{1}
\pgfmathsetmacro{\y}{2}
\pgfmathsetmacro{\z}{2.5}
\pgfmathsetmacro{\step}{0.025}
% coordinates in spherical coordinates
\pgfmathsetmacro{\radio}{sqrt(\x*\x+\y*\y+\z*\z)}
\pgfmathsetmacro{\zf}{\radio+0.25} % To indicate the end point in the z axis
\pgfmathsetmacro{\angulot}{atan(\y/\x)} % angle $\theta$
\pgfmathsetmacro{\dominio}{\angulot*pi/180} % Convert $\theta$ into radians
\pgfmathsetmacro{\angulop}{acos(\z/\radio)} % angle $\phi$
\pgfmathsetmacro{\dominiop}{\angulop*pi/180} % Convert $\phi$ into radians
% Diferencial
\pgfmathsetmacro{\dradio}{0.75} % Differential of $r$
\pgfmathsetmacro{\dangulot}{10} % Differential of $\theta$
\pgfmathsetmacro{\dangulop}{10} % Differential of $\phi$
\pgfmathsetmacro{\dominiof}{(\angulot+\dangulot)*pi/180}
% Vertices of the differential of area
% on the xy plane (in polar coordinates)
\pgfmathsetmacro{\Ax}{\radio*cos(\angulot)}
\pgfmathsetmacro{\Ay}{\radio*sin(\angulot)}
\pgfmathsetmacro{\Bx}{(\radio+\dradio)*cos(\angulot)}
\pgfmathsetmacro{\By}{(\radio+\dradio)*sin(\angulot)}
\pgfmathsetmacro{\Cx}{(\radio+\dradio)*cos(\angulot+\dangulot)}
\pgfmathsetmacro{\Cy}{(\radio+\dradio)*sin(\angulot+\dangulot)}
\pgfmathsetmacro{\Dx}{(\radio)*cos(\angulot+\dangulot)}
\pgfmathsetmacro{\Dy}{(\radio)*sin(\angulot+\dangulot)}
%
\pgfmathsetmacro{\radiof}{\radio+\dradio}
\pgfmathsetmacro{\radiorayo}{\radiof+2.0*\dradio}
\pgfmathsetmacro{\angulotf}{\angulot+\dangulot}
\pgfmathsetmacro{\angulopf}{\angulop+\dangulop}
% Location of the node to indicate the angles $\theta$ and $\phi$
\pgfmathsetmacro{\xnodo}{0.35*cos(0.5*\angulot)}
\pgfmathsetmacro{\ynodo}{0.35*sin(0.5*\angulot)}
\pgfmathsetmacro{\xnodop}{0.35*sin(0.5*\angulop)*cos(\angulot)}
\pgfmathsetmacro{\ynodop}{0.35*sin(\angulop)*sin(\angulot)}
\pgfmathsetmacro{\znodop}{0.35*cos(0.5*\angulop)}
\pgfmathsetmacro{\xnododp}{0.85*\radio*sin(0.5*(\angulop+\angulopf))*cos(\angulot)}
\pgfmathsetmacro{\ynododp}{0.85*\radio*sin(0.5*(\angulop+\angulopf))*sin(\angulot)}
\pgfmathsetmacro{\znododp}{0.85*\radio*cos(0.5*(\angulop+\angulopf))}
%
\pgfmathsetmacro{\xfrayouno}{(\radiof+0.5)*cos(\angulot)}
\pgfmathsetmacro{\yfrayouno}{(\radiof+0.5)*sin(\angulot)}
\pgfmathsetmacro{\xfrayodos}{(\radiof+0.5)*cos(\angulotf)}
\pgfmathsetmacro{\yfrayodos}{(\radiof+0.5)*sin(\angulotf)}
% Vertices of the differential of area in spherical coordinates
\pgfmathsetmacro{\Px}{\radio*sin(\angulopf)*cos(\angulot)}
\pgfmathsetmacro{\Py}{\radio*sin(\angulopf)*sin(\angulot)}
\pgfmathsetmacro{\Pz}{\radio*cos(\angulopf)}
\pgfmathsetmacro{\Sx}{\radio*sin(\angulop)*cos(\angulot)}
\pgfmathsetmacro{\Sy}{\radio*sin(\angulop)*sin(\angulot)}
\pgfmathsetmacro{\Sz}{\radio*cos(\angulop)}
%
\pgfmathsetmacro{\Tx}{\radio*sin(\angulopf)*cos(\angulotf)}
\pgfmathsetmacro{\Ty}{\radio*sin(\angulopf)*sin(\angulotf)}
\pgfmathsetmacro{\Tz}{\radio*cos(\angulopf)}
\pgfmathsetmacro{\Wx}{\radio*sin(\angulop)*cos(\angulotf)}
\pgfmathsetmacro{\Wy}{\radio*sin(\angulop)*sin(\angulotf)}
\pgfmathsetmacro{\Wz}{\radio*cos(\angulop)}
% The origin
\coordinate (O) at (0,0,0);
% Coordinate axis
\draw[thick,->] (0,0,0) -- (\radiof+0.5,0,0) node [below left] {$x$};
\draw[thick,->] (0,0,0) -- (0,\radiof+0.5,0) node [right] {$y$};
\draw[thick,->] (0,0,0) -- (0,0,\zf+0.5) node [above] {$z$};
% Horizontal radius of length $\rho\,\sin\phi$
\draw[blue,<->] (0,0,\z) -- (\Sx,\Sy,\Sz) node [midway,sloped,fill=white] {\tiny$\rho\,\sin\phi$};
% Intersection of the sphere of radius $\rho$ with the plane $y = 0$
\draw[blue,dashed] plot[domain=0:0.5*pi,smooth,variable=\t] ({\radio*sin(\t r)},{0.0},{\radio*cos(\t r)});
% Differential of area in polar coordinates (on the xy-plane)
\draw[blue,dashed](0,0,0) -- (\xfrayouno,\yfrayouno,0) node[below left] {$\theta$};
\draw[blue,dashed](0,0,0) -- (\xfrayodos,\yfrayodos,0) node [below right] {$\theta + d\theta$};
% Indication of the angle $\theta$
\draw[blue] plot[domain=0:\dominio,smooth,variable=\t] ({0.5*cos(\t r)},{0.5*sin(\t r)},{0.0}); % 0.5236
\node[blue,below] at (\xnodo,\ynodo,0) {$\theta$};
%
\draw[blue,dashed] plot[domain=0:0.5*pi,variable=\t] ({\radio*cos(\t r)},{\radio*sin(\t r)},0.0);
\node[blue,above left] at (\radio,0,0) {$\rho$};
% Plane at $\theta + d\theta$ (inside of the sphere)
\draw[blue,dashed,fill=yellow!50,opacity=0.35]
(0,0,0) -- (\Dx,\Dy,0) -- plot[domain=0.5*pi:0.0,smooth,variable=\t]
({\radio*sin(\t r)*cos(\angulotf)},{\radio*sin(\t r)*sin(\angulotf)},{\radio*cos(\t r)})
-- (0,0,0);
% lines from the origin to the differential of surface area
\draw[blue,dashed] (O) -- (\Tx,\Ty,\Tz);
\draw[blue,dashed] (O) -- (\Wx,\Wy,\Wz);
% Plane at $\theta$ (inside the sphere)
\draw[blue,dashed,fill=yellow!50,opacity=0.35]
(0,0,0) -- (\Ax,\Ay,0) -- plot[domain=0.5*pi:0.0,smooth,variable=\t]
({\radio*sin(\t r)*cos(\angulot)},{\radio*sin(\t r)*sin(\angulot)},{\radio*cos(\t r)})
-- (0,0,0);
% Lines from the origin to the differential of surface area
\draw[blue,dashed] (O) -- (\Px,\Py,\Pz);
\draw[blue,dashed] (O) -- (\Sx,\Sy,\Sz);
% Arc to indicate the angle $\phi$
\draw[blue] plot[domain=0:\dominiop,smooth,variable=\t] ({0.5*sin(\t r)*cos(\angulot)},{0.5*sin(\t r)*sin(\angulot)},{0.5*cos(\t r)});
\node[blue,above] at (\xnodop,\ynodop,\znodop) {$\phi$};
\node[blue] at (\xnododp,\ynododp,\znododp) {$d\phi$};
% Intersection of the sphere of radius $\rho$ with the plane $x = 0$
\draw[blue,dashed] plot[domain=0:0.5*pi,smooth,variable=\t] ({0.0},{\radio*sin(\t r)},{\radio*cos(\t r)});
% Sphere of radius $\rho$
\foreach \altura in {0,\step,...,\radio}{
\pgfmathsetmacro{\r}{sqrt((\radio)^2-(\altura)^2)}
\draw[cyan,line width=3pt,opacity=0.05] plot[domain=0:0.5*pi,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{\altura});
\draw[cyan,thin,opacity=0.25] plot[domain=0:0.5*pi,smooth,variable=\t] ({\r*cos(\t r)},{\r*sin(\t r)},{\altura});
}
% The differential of sufrace area in spherical coordinates
\draw[red,thick,fill=red,opacity=0.5] (\Px,\Py,\Pz) -- (\Tx,\Ty,\Tz) -- (\Wx,\Wy,\Wz) -- (\Sx,\Sy,\Sz) -- (\Px,\Py,\Pz);
% Nodes indicating lengths in the differential of surface area
\pgfmathsetmacro{\SWmx}{0.5*(\Sx+\Wx)}
\pgfmathsetmacro{\SWmy}{0.5*(\Sy+\Wy)}
\pgfmathsetmacro{\SWmz}{0.5*(\Sz+\Wz)}
\draw[<-,shift={(\SWmx,\SWmy,\SWmz)}] (0,0,0) -- (-0.5,0.5,1) node [above] {\footnotesize$\rho\,\sin\phi\,d\theta$};
\pgfmathsetmacro{\TWmx}{0.5*(\Wx+\Tx)}
\pgfmathsetmacro{\TWmy}{0.5*(\Wy+\Ty)}
\pgfmathsetmacro{\TWmz}{0.5*(\Wz+\Tz)}
\draw[<-,shift={(\TWmx,\TWmy,\TWmz)}] (0,0,0) -- (-1,1,0.5) node [right] {\footnotesize$\rho\,d\phi$};
\pgfmathsetmacro{\PTmx}{0.5*(\Px+\Tx)}
\pgfmathsetmacro{\PTmy}{0.5*(\Py+\Ty)}
\pgfmathsetmacro{\PTmz}{0.5*(\Pz+\Tz)}
\node[red,below right] at (\PTmx,\PTmy,\PTmz) {$dS$};
\end{tikzpicture}
\end{center}
%
\end{document}
Click to download: differential-of-surface-area-spherical-coordinates.tex • differential-of-surface-area-spherical-coordinates.pdf
Open in Overleaf: differential-of-surface-area-spherical-coordinates.tex
See more on the author page of Efraín Soto Apolinar.
