我有一个1800 * 100000000矩阵,我想使用下面的代码在python中绘制它:
import matplotlib.pyplot as plt
plt.spy(m)
plt.show()
结果令人失望,它看起来像一条线,因为与列号相比,行数很少:
我该如何正确地做到这一点?
答案 0 :(得分:1)
spy()
accepts a number of keyword arguments, aspect
in particular is interesting...
In [1]: import numpy as np
In [2]: import matplotlib.pyplot as plt
In [3]: a = np.random.random((25,250))>0.6
In [4]: %matplotlib
Using matplotlib backend: Qt4Agg
In [5]: plt.spy(a)
Out[5]: <matplotlib.image.AxesImage at 0x7f9ad1a790b8>
In [6]: plt.spy(a, aspect='auto')
Out[6]: <matplotlib.image.AxesImage at 0x7f9ad1139d30>