Tom Dawn Tom Dawn - 6 months ago 25
Python Question

python plot large dimension data

I have a 1800*100000000 matrix, and I want to plot it in python using code below:

import matplotlib.pyplot as plt
plt.spy(m)
plt.show()


The result is disappointing, it looks like a line because of little row number compared to column number:

enter image description here

How can I do it correctly?

Answer

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>

standard

In [6]: plt.spy(a, aspect='auto')
Out[6]: <matplotlib.image.AxesImage at 0x7f9ad1139d30>

enter image description here

Comments