numpy 行列(配列) array に対する操作
*行列の左右のみを反転させる.
numpy.fliplr(a)
http://docs.scipy.org/doc/numpy/reference/generated/numpy.fliplr.html
*転置行列
a.T
*行列形式のデータの表示
matplotlib.pyplot.imshow(a, interpolation=’nearest’)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import numpy as np a = np.array([[10, 8, 6], [ 9, 4, 2], [ 7, 3, 1], [ 5, 1, 0]]) np.fliplr(a) array([[ 6, 8, 10], [ 2, 4, 9], [ 1, 3, 7], [ 0, 1, 5]]) a.T array([[10, 9, 7, 5], [ 8, 4, 3, 1], [ 6, 2, 1, 0]]) import matplotlib.pyplot as plt plt.imshow(a, interpolation='nearest') plt.colorbar() |