dorien - 2 months ago 12

Python Question

I am drawing a plot based on a numpy array:

`A = np.array([[4,5,6],[2,3,6]])`

with plt.plot(A) it works fine and draws based on 6 tuples: (0,4), (1,5), (2,6), (0,2) etc.

I want to scale the x-axis though. The units should be divided by 120. So I want to plot:

`(0,4), (1/120,5), (2/120, 6), etc.`

Is there any easy way to do it, without looping through the array and manually feeding the tuples to the plot?

Answer

Specify the x axis

```
scaling_factor = 120.
x = np.arange(A.shape[0])/scaling_factor
plt.plot(x, A)
```