Q:

How to properly scale graph of highly disproprtionate matrix in matplotlib?

I have a set of matrices I'm graphing with plt.matshow(matrix) and it works fine for matrices with dimensions that are close to each other (i.e. 56,000 x 5,000 or 64x6). However, when I try it with a 56,000x6 matrix, I just get a really large scale and no graph (See attached image), which I suspect is due to matplotlib not being sure how to scale the image. Does anyone know how to handle this?

A:

you could use a logarithmic scale:
import matplotlib.pyplot as plt
import numpy as np

# dummy matrix:
a = np.arange(20000).reshape(10000, 2)

plt.matshow(a)
plt.yscale('log')

plt.show()

Alternatively, you can manually change the aspect of your plot:
plt.matshow(a)
plt.gca().set_aspect(0.0001)

