[Numpy-discussion] Producing a Histogram When Bins Are Known

Christopher Barker Chris.Barker@noaa....
Fri Nov 27 11:41:50 CST 2009


Wayne Watson wrote:
> Yes, I'm just beginning to deal with the contents of NumPy, SciLab, and 
> SciPy. They all have seemed part of one another, but I think I see how 
> they've divided up the game. 

For the record:

I know this is a bit confusing, particularly for someone used to an 
integrated package like Matlab, etc, but there is a lot of power an 
flexibility gained by the divisions:

Python: is a general-purpose, extensible programming language

Numpy: is a set of package of classes, functions, etc that provide 
facilities for numeric computation -- primarily a n-d array class and 
the utilities to use it.

Matplotlib (MPL): is a plotting package, built on top of numpy -- it was 
originally designed to somewhat mimic the plotting interface of Matlab. 
MPL is the most commonly used plotting package for numpy, but by no 
means the only one.

Pylab: Is a package that integrates matplotlib and numpy and an 
assortment of other utilities into one namespace, making it more like 
Matlab -- personally, I think you should avoid using it, it makes it a 
bit easier to type code, but harder to know where the heck what you are 
doing is coming from.

SciPy: Is a broad collection of assorted utilities that facilitate 
scientific computing, built on Numpy -- it is also sometimes used as an 
umbrella term for anything connected to scientific computing with Python 
(i.e. the SciPy conferences)


These distinctions are a bit confusing (particularly MPL-numpy), because 
MPL includes a number of utility functions that combine computation and 
plotting: like "hist", which both computes a histogram, and plots it as 
bar chart in one call -- it's a convenient way to perform a common 
operation, but it does blur the lines a bit!

By the way -- there is also potentially a bit of confusion as to how MPL 
uses/interacts with the command line and GUI toolkits. This is because 
MPL can be used with a number of different GUI front-ends (or none), and 
they tend to take over control from the command line. Which brings up to:

iPython: an enhanced python interactive interpreter command line system. 
It adds many nice features that make using python in interactive mode 
nicer. IN particularly, it adds a "--pylab" mode that helps it play well 
with MPL. You won't regret using it!


> I thought I'd look through Amazon 
> for books on Python and scientific uses. I found almost all were written 
> by authors outside the US, and none seemed to talk about items like 
> matplotlib.

FWIW, a book about MPL has just been published -- I don't know any more 
about it, but I'm sure google will tell you.

> Is there a matplotlib or Pylab mailing list?

There certainly is:

https://lists.sourceforge.net/lists/listinfo/matplotlib-users

And yes, that is the place for such questions.


HTH,

-Chris



-- 
Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

Chris.Barker@noaa.gov


More information about the NumPy-Discussion mailing list