对于刚接触matpltlib的程序员,一般都只使用它的pyplot就够用了,下面是两个非常简单的例子
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
x = np.linspace(0,10,100)
y = np.sin(x)
cosy = np.cos(x)
siny = y.copy()
plt.scatter(x, cosy, color='red', linestyle='--', label='cos')
plt.plot(x, siny, color='#009900', linestyle='-.', label='sin')
plt.xlim(-1, 11)
plt.ylim(-1.5,1.5)
plt.ylabel('y')
plt.xlabel('x')
plt.legend()
plt.title('test pyplot .....')
plt.show()
x = np.random.normal(0,1,10000)
y = np.random.normal(0,1,10000)
plt.scatter(x,y, alpha=0.5)
plt.show()