ScipySparse - t-sakashita/rokko GitHub Wiki
Scipyのsparseパッケージ
MATLABと同様にspy関数で疎行列をプロットできる。
http://matplotlib.org/examples/pylab_examples/spy_demos.html
http://stackoverflow.com/questions/18651869/scipy-equivalent-for-matlab-spy
テキストファイルで行列を読み書き
http://hydrocul.github.io/wiki/numpy/ndarray-io.html
行列を読み込み描画
import numpy as np
import matplotlib.pylab as plt
A = np.loadtxt('matrix.txt')
A.shape
plt.spy(A)
plt.show()
Matrix Market形式の行列データのを読み込み描画
import scipy.io
import matplotlib.pylab as plt
A = scipy.io.mmread("output.mtx")
plt.spy(A, markersize = 0.5, precision = 0)
plt.show()
フォントの埋め込み
matplotlib.use('pdf')
matplotlib.rc('pdf', fonttype=42)
参考: http://stackoverflow.com/questions/9054884/how-to-embed-fonts-in-pdfs-produced-by-matplotlib
Matrix Market形式の行列データを読み込み描画(MATLABの場合)
mmread.mを以下からとってくる。 http://math.nist.gov/MatrixMarket/mmio/matlab/mmiomatlab.html
A = mmread('~/build/rokko-clang/example/cxx/sparse/output.mtx')
spy(A)
pythonのmatplotlibとほぼ同様の描画結果が得られる。