绘制矩阵:默认横坐标为0,1,2,3……
from numpy import * a=mat([[9,8,5,6,3],[1,3,7,10,8],[1,2,3,4,5],[1,3,7,10,8]]) import matplotlib.pyplot as plt fig=plt.figure() ax=fig.add_subplot(111) ax.plot(a) plt.show()
输出:
设置横坐标:-3,-2,-1,0 axisX的元素个数要与矩阵的行数相等。
from numpy import * a=mat([[9,8,5,6,3],[1,3,7,10,8],[1,2,3,4,5],[1,3,7,10,8]]) import matplotlib.pyplot as plt fig=plt.figure() ax=fig.add_subplot(111) axisX=[i-3 for i in range(4)] ax.plot(axisX,a) plt.show()
输出: