nerdizzle nerdizzle - 1 year ago 84
Python Question

why does the plot not show the correct range on the x-axis?

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 Source

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


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))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download