Don’t know that I can find anything to make it more organized. You can improve the efficiency. I was told computation speed will improve the less you send code back and forth between CL and the graph. With that in mind, I would define in this way:
number(`a_1`): a1
a1 = r.int(2,9)
Your method takes the random generator and sends it to the graph to define a_1, then pulls that value back out to define a1 in the CL.
Also, you can use variables in a graph to define your point labels, so rather than defining them in the CL, you can define, A_1 for example, in the graph by using this for your label (note the backticks for latex):