nerdizzle - 4 months ago 7

Python Question

I have a question about the accepted answer given in this thread. I have tested the answer and I wonder why the x-axis goes from 0 to 120 and not from -3 to 3?

Answer

`mp.plot()`

is called with only one argument (array of Y-values), which means the corresponding X-values are natural numbers (starting from 0).

[edit]

To have the X-axis from -3 to 3 it is necessary to pass the X values explicitely:

```
X = np.linspace(-3, 3, 120)
mp.plot(X, gaussian(X, mu, sig))
```

Source (Stackoverflow)

Comments