I'm trying to replicate this figure:

enter image description here

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[italic = true]{derivative}
\usepackage[scr = rsfso]{mathalfa} 

\pgfplotsset{compat = newest}

    \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}

        \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) 

        \draw[dashed, bleudefrance] (pxy) -- (p);

that produces

enter image description here

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


1 Answer 1


Something to start with:

\usetikzlibrary{3d, fillbetween}

    \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);

        % 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);

        % 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}$};
        \draw[fill=red] (A1) circle[radius=3pt];

        % angle
        \begin{scope}[canvas is xz plane at y=0]
            \draw[->] (0,1) arc[start angle=90, end angle=30, radius=1] 
                node[midway, below] {$\phi$};

enter image description here

  • 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?
    – Peluche
    Feb 21 at 21:09
  • 1
    @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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .