一、用一个简单的例子认识matplotlib

import numpy as np
import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [1, 4, 6, 16])

fig, ax = plt.subplots()
ax.plot([1, 2, 3, 4], [1, 4, 6, 16]);

plt.plot([1,2,3,4],[7,43,25,67])
plt.show()

二、Figure的组成
 
三、两种绘图接口

1、显式创建figure和axes
x = np.linspace(0, 2, 100)
fig, ax = plt.subplots()
ax.plot(x, x, label='linear')
ax.plot(x, x**2, label='quadratic')
ax.plot(x, x**3, label='cubic')
ax.set_xlabel('x label')
ax.set_ylabel('y label')
ax.set_title('simple plot')
ax.legend()
plt.show()
 顺便复习一下subplots()吧
2、直接用pyplot自动创建figure和axes
x = np.linspace(0, 2, 100)
plt.plot(x, x, label='linear')
plt.plot(x, x**2, label='quadratic')
plt.plot(x, x**3, label='cubic')
plt.xlabel('x label')
plt.ylabel('y label')
plt.title('simple plot using pyplot.plot')
plt.show()

|