The Collatz sequence
Given a positive integer \$a_1\$, the Collatz sequence with starting value \$a_1\$ is defined as \begin{equation} a_{n+1} = \begin{cases} a_n/2 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{even} \\ 3a_n+1 & \mathrm{if}\ a_n\ \mathrm{is}\ \mathrm{odd}. \end{cases} \end{equation} It is conjectured that, for any starting value, this sequence always reaches the number \$1\$. This challenge assumes that the conjecture is true.
The challenge
Given an integer \$a_1 > 2\$, compute the Collatz sequence until \$1\$ is reached for the first time. Let \$N\$ be the number of sequence terms (including \$a_1\$ and \$a_N = 1\$). From the sequence of numbers \begin{equation} a_1, a_2, a_3, \ldots, a_N \end{equation} form a sequence of points in the plane by taking all pairs of consecutive terms \begin{equation} (a_1, a_2), (a_2, a_3), \ldots, (a_{N-1}, a_N) \end{equation} and plot these points on a 2D graph, joining consecutive points by a line segment.
Example
For input \$12\$ the Collatz sequence is (\$10\$ terms); \begin{equation} 12, 6, 3, 10, 5, 16, 8, 4, 2, 1. \end{equation} The sequence of points is (\$9\$ points): \begin{equation} (12, 6), (6, 3), (3, 10), (10, 5), (5, 16), (16, 8), (8, 4), (4, 2), (2, 1). \end{equation} The plot contains \$8\$ line segments, as shown in the following graph. Note that some of the segments partially overlap. For clarity, the plot includes markers at the \$9\$ points.
Additional rules
- Graphical output is required, with output being flexible as usual.
- Only the straight lines are required in the graph. Line width is flexible, as long as the plot can be seen reasonably well. Line color is also flexible, and may be different for each segment, as long as lines are distinguishable from the background.
- Other elements in the graph are not required, but are allowed (point markers, grid lines, axis labels, ...).
- Horizontal and vertical axis scales need not be the same. Axis limits are arbitrary, as long as the graph can be seen fully and clearly. The axes may be swapped, and each axis may be reversed.
- The code should work for any input given unlimited resources. It is acceptable if in practice it fails for large inputs due to time, memory or data-type limitations.
- If the input happens to be a counterexample for the Collatz conjecture the code can do anything, such as get stuck in an infinite loop or order a pizza.
- Programs or functions are accepted. Standard loopholes are forbidden.
- Shortest code in bytes wins.