Values of the expression $ax \pmod b$ as a function of $x$ I'm trying to better understand behavior of the expression $(ax\pmod b)$ as a function of $x \in \Bbb N$. Both constant numbers $a \in \Bbb N$ and $b \in \Bbb N$, and also we can assume that the number $a$ is prime. For example, the graph below shows the function $(31 x \mod 12)$ for $x \in [0,11]$.

We can see three monotonically increasing subsequences here, which fit on three straight lines:

*

*$(0,0),(2,2),(4,4),(6,6),(8,8),(10,10)$ - for even $x \in [0,10]$

*$(1,7),(3,9),(5,11)$ - for odd $x \in [1,5]$

*$(7,1),(9,3),(11,5)$ - for odd $x \in [7,11]$
Of course, there are many other straight lines here, but I need to consider a minimal number of such lines. It's clear that this picture depends on values of $a$ and $b$. For example, the expression $(37x \mod 12)$ will give us a single straight line:

Is it any theory, which can predict configuration of these lines in general case, for any $a$ and $b$?
 A: The graph of $y \equiv 31x \pmod{12} : x \in \mathbb{Z^+}, 
y \in \{0,1,2, \cdots, 11\}$ can be interpreted as follows.
For $y \in \mathbb{Z^+},$ let $r(y)$ denote the unique value $k$ in
$\{0,1,2, \cdots, 11\}$ 
such that $y \equiv k\pmod{12}.$
First, since $31 \equiv 7\pmod{12},$
start with the graph of $y = 7x.$
Then, replace each point $(x,y)$ with $(x,r(y))$.
Addendum 
Per OP's request.
Consider the general case of $y = ax \pmod{b}.$ 
The specification of $a =$ a prime number 
is covered under the more general specification 
that $a$ and $b$ are relatively prime.
Let the set $U \equiv \{0,1,2, \cdots, (b-1)\}.$ 
For $y \in \mathbb{Z^+},$ let $r(y)$ denote the unique value $k$ in $U$ such that $y \equiv k\pmod{b}.$
Let the set $T \equiv \{r(0), r(1), r(2), \cdots, r(b-1)\}.$ 
It is well settled, that since
$a$ and $b$ are relatively prime, 
the set $T$ is the same as the set $U$, except for the
ordering of the elements.
Further, for $m \in \mathbb{Z^+},~$
let the set
$$T_m \equiv 
\{r([b\times m] + 0), r([b\times m] + 1), r([b\times m] + 2), \cdots, r([b\times m] + b-1)\}.$$
Then, the set $T_m$ will be the same as the set $T$, with
the elements appearing in the same order.
To graph the function: 
start with the graph of $y = ax,$ 
then, replace each point $(x,y)$ with $(x,r(y))$.
