0

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?

Community
  • 1
  • 1
nerdizzle
  • 424
  • 4
  • 17

1 Answers1

1

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))
abukaj
  • 2,582
  • 1
  • 22
  • 45