[SciPy-User] book on scipy

rex rex@nosyntax....
Fri Jul 31 10:46:13 CDT 2009

Emmanuelle Gouillart <emmanuelle.gouillart@normalesup.org> [2009-07-31 06:37]:
>> But don't overlook the Cookbook:
>> http://www.scipy.org/Cookbook
>And if you want to read through a comprehensive and step-by-step
>document, have a look at the scipy tutorial
>http://docs.scipy.org/doc/scipy/reference/tutorial/ and the numpy
>tutorial http://www.scipy.org/Tentative_NumPy_Tutorial 

There's also:


Speaking of which, this example below does not work correctly with
matplotlib-0.98.1-1+lenny4 (the most recent in the Debian repository).


mu, sigma = 0.05, 0.25 # mean and standard deviation 
s = np.random.lognormal(mu, sigma, 100000)

import matplotlib.pyplot as plt
count, bins, ignored = plt.hist(s, 100, normed=True, align='center')
x = np.linspace(min(bins), max(bins), 10000)
pdf = (np.exp(-(np.log(x) - mu)**2 / (2 * sigma**2))/(x * sigma * np.sqrt(2 * np.pi)))
plt.plot(x, pdf, linewidth=2, color='r')

It's visually apparent that the histogram is offset to the left
from where it should be.

>>help(plt.hist) reveals that:

*align*: ['left' | 'mid' | 'right' ]

With the 'mid' keyword, the plot is correctly centered on the pdf.

'left, center, right' is certainly easier to remember than 'left',
'mid',  'right'.  

In any case, shouldn't it throw an error rather than silently
defaulting to 'left' when the 'align' keyword isn't one of the magic 3?


More information about the SciPy-User mailing list