# How to draw the solids to refer to cylindricals coordinates

I'm trying to replicate this figure:

but I don't know how to draw these planes. I need to draw the plane for constant z, rho and phi. I know that, to draw this, many lines of code are needed but the ideal answer should be simple and easy to understand and to modify.

Right now, I only have this code

\documentclass[11pt, oneside]{book}

\usepackage{physics}
\usepackage[italic = true]{derivative}
\usepackage[scr = rsfso]{mathalfa}
\usepackage{mathtools}
\usepackage{amssymb}

\usepackage{pgfplots}

\usepackage{tikz-3dplot}
\usepackage{tikz}
\usetikzlibrary{snakes, calc, quotes, babel,
decorations, trees, arrows, patterns, patterns.meta,
decorations.pathreplacing, calligraphy, backgrounds,
decorations.pathmorphing, decorations.markings, hobby,
chains, shapes.geometric, shapes, angles, 3d}

\begin{figure}[H]
\centering
\begin{tikzpicture}[yzx]
\draw[->] (0,0,0) -- (5,0,0) node(x)[left]{$x$};
\draw[->] (0,0,0) -- (0,6,0) node(y)[right]{$y$};
\draw[->] (0,0,0) -- (0,0,4) node(z)[right]{$z$};

\def\px{3}; \def\py{5}; \def\pz{2};

\coordinate (o) at (0,0,0);
\coordinate (p) at (\px,\py,\pz);
\coordinate (pxy) at (\px,\py,0);

\def\Arho{((\px)^2 + (\py)^2)^0.5};

\filldraw[bleudefrance] (p) circle(2pt)
node[right]{$(\rho, \phi, z)$};

%\draw (o) -- (p);

\pic[draw, dashed, "$\phi$", bleudefrance, angle eccentricity = 2, angle radius = 1cm] {angle = x--o--pxy};
%\draw pic[draw,fill=green!30,angle radius=1cm,"$\alpha$" shift={(6mm,1mm)}] {angle=x--o--pxy};

\draw[dashed, bleudefrance] (o) -- (pxy) node(r)[below, pos = 0.5]{$\rho$};

\filldraw[bleudefrance] (pxy) circle(1pt)
node[right]{$P'$};

\draw[dashed, bleudefrance] (pxy) -- (p);
\end{tikzpicture}
\end{figure}


that produces

I don't know how to draw these "solid planes"

• What have you tried so far? Feb 21 at 19:37
• It should not be too complicated. Start by \draw[->]ing the three axes, then add the grey block which you can just draw using three 2D shapes. You don't really need a 3D environment for this (except you really want this). Feb 21 at 19:46
• I've been reading some posts, like [tex.stackexchange.com/questions/42812/3d-bodies-in-tikz](this) (for the cylinder) and [tex.stackexchange.com/questions/32077/… for the plane of z = const). It's too much for me, I'm a noob at drawing 3d plots Feb 21 at 19:47

\documentclass[border=10pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usetikzlibrary{3d, fillbetween}

\begin{document}
\begin{tikzpicture}[line join=round]
\draw[->] (0,0,0) -- (5,0,0) node[right] {$y$};
\draw[->] (0,0,0) -- (0,5,0) node[right] {$z$};
\draw[->] (0,0,0) -- (0,0,5) node[right] {$x$};

% top arc and coordinate
\begin{scope}[canvas is xz plane at y=4]
\path[name path global=top]
(3,0) arc[start angle=0, end angle=30, radius=3]
coordinate (A1);
\end{scope}

% bottom arc
\begin{scope}[canvas is xz plane at y=0]
\path[name path global=bottom]
(3,0) arc[start angle=0, end angle=30, radius=3]
coordinate (A2);
\end{scope}

% right side
\draw[fill=black!40, intersection segments={of=top and bottom, sequence={L* -- R*[reverse]}}] -- cycle;

% left side
\draw[fill=black!20] (0,4,0) -- (A1) -- (A2) -- (0,0,0) -- cycle;

% top side
\draw[fill=black!60, intersection segments={of=top and bottom, sequence={L*}}] -- (0,4,0) node[midway, below] {$\rho$} -- cycle;

% red dot and three arrows
\draw[very thick, ->] (A1) -- ++(0,1,0) node[left] {$\hat{k}$};
\begin{scope}[canvas is xz plane at y=4]
\draw[very thick, ->] (A1) -- ++(30:1) node[below] {$\hat{\rho}$};
\draw[very thick, ->] (A1) -- ++(-60:1) node[right] {$\hat{\phi}$};
\end{scope}
node[midway, below] {$\phi$};

• you're a genius. By the way, I have two questions: what is [line join=round] and sequence={L* -- R*[reverse]} for? Where can I read more about this? Feb 21 at 21:09
• @Peluche line join=round is to make sharp corners less sharp. Otherwise you would see some overlaps at sharp corners. As for sequence, this is part of the fillbetween library for pgfplots (which is why I did not load tikz but pgfplots Actually). You can find more about this in the PGFplots manual. With this I essentially redraw the arc parts. Feb 21 at 21:14