[Tex/LaTex] TikZ: Draw angle with label between lines

diagramstechnical-drawingtikz-pgf

How do I draw an angle with a label between two lines when the lines are not necessarily drawn in the same \draw call?

I need to draw an angle with a label, theta, between the y-axis and the pendulum string (see picture below).

Other suggestions/improvements of my code/diagram are welcome.

Current code:

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,patterns}
\begin{document}
\begin{tikzpicture}
\coordinate (origo) at (0,0);
\coordinate (pivot) at (1,5);

% draw axes
\fill[black] (origo) circle (0.05);
\draw[thick,gray,->] (origo) -- ++(4,0) node[black,right] {$x$};
\draw[thick,gray,->] (origo) -- ++(0,-4) node[black,below] {$y$};

% draw roof
\fill[pattern = north east lines] ($ (origo) + (-1,0) $) rectangle ($ (origo) + (1,0.5) $);
\draw[thick] ($ (origo) + (-1,0) $) -- ($ (origo) + (1,0) $);

\draw[thick] (origo) -- ++(300:3) coordinate (bob);
\fill (bob) circle (0.2);
\end{tikzpicture}
\end{document}

Current output:

enter image description here

For illustration, I want something like this in my diagram:

enter image description here

Best Answer

You can use the angles library which defines a pic for this purpose. The quotes library is used for ease of labelling.

\documentclass[tikz,border=10pt]{standalone}
\usetikzlibrary{calc,patterns,angles,quotes}
\begin{document}
  \begin{tikzpicture}
    \coordinate (origo) at (0,0);
    \coordinate (pivot) at (1,5);

    % draw axes
    \fill[black] (origo) circle (0.05);
    \draw[thick,gray,->] (origo) -- ++(4,0) node[black,right] {$x$};
    \draw[thick,gray,->] (origo) -- ++(0,-4) node (mary) [black,below] {$y$};

    % draw roof
    \fill[pattern = north east lines] ($ (origo) + (-1,0) $) rectangle ($ (origo) + (1,0.5) $);
    \draw[thick] ($ (origo) + (-1,0) $) -- ($ (origo) + (1,0) $);

    \draw[thick] (origo) -- ++(300:3) coordinate (bob);
    \fill (bob) circle (0.2);

    \pic [draw, ->, "$\theta$", angle eccentricity=1.5] {angle = mary--origo--bob};
  \end{tikzpicture}
\end{document}

marked angle

If you want the angle in red with two-way arrows, just modify the last line:

\pic [draw=red, <->, "$\theta$", angle eccentricity=1.5] {angle = mary--origo--bob};

modified marked angle

EDIT (Respond to query in comments)

To change the colour of the label as well, just set the text key:

\pic [draw=red, text=blue, <->, "$\theta$", angle eccentricity=1.5] {angle = mary--origo--bob};

modified modified marked angle