Pylab combines the functionality of pyplot with the capabilities of NumPy in a single namespace, and therefore you do not need to import NumPy separately. Furthermore, if you import pylab, pyplot, and NumPy functions can be called directly without any reference to a module (namespace), making the environment more similar to Matlab.

使用pylab

from pylab import *
...
plot(x,y)
array([1,2,3,4])

使用pyplot

import matplotlib.pyplot as plt
import numpy as np
...
plt.plot()
np.array([1,2,3,4])

相关文章: