[Numpy-discussion] standard pyplot, numpy, scipy import syntax

Eric Firing efiring@hawaii....
Sat Apr 12 18:26:41 CDT 2008


In reference to:
http://news.gmane.org/find-root.php?message_id=%3cc7009a550804100055g6388b20ej520e85d8e679a55%40mail.gmail.com%3e

A point was brought up that deserves wider dissemination and a 
correction, hence my posting to two lists.

To reduce confusion among new users and to improve code readability, 
participants in a numpy sprint, including John D. Hunter (remotely), 
agreed to promote the following standard:

import numpy as np
import scipy as sp
import matplotlib.pyplot as plt

This differs from the message referenced above in that the standard 
entrance point for the plotting functionality of pylab is the pyplot 
module of matplotlib, not the pylab module.  Pyplot is a fairly recent 
addition that provides the state-machine plotting interface; pylab is 
essentially the result of dumping pyplot and numpy into a single 
namespace, which is sometimes convenient for interactive use but 
certainly is not encouraged for programming.

The recommended standard is intended to promote consistency and 
readability in the numpy, scipy, and matplotlib families of modules, and 
in their documentation; it is not intended to imply any restriction on 
the user's freedom.  The recommendation may be helpful in your own code, 
or it may not; use it where it helps.

This message is intended to be informational; it is not a trial balloon, 
and it is not intended to stimulate discussion.  I hope the related 
discussions that have already occurred on the numpy and matplotlib lists 
will suffice.

Eric


More information about the Numpy-discussion mailing list