Last active
July 8, 2019 16:23
-
-
Save lukeolson/9710288 to your computer and use it in GitHub Desktop.
matplotlib like color spy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fastspy(A, ax, cmap=None): | |
"""" | |
Parameters | |
---------- | |
A : coo matrix | |
ax : axis | |
""" | |
m, n = A.shape | |
ax.hold(True) | |
ax.scatter(A.row, A.col, c=A.data, s=20, marker='s', | |
edgecolors='none', clip_on=False, | |
cmap=cmap) | |
ax.axis('off') | |
ax.axis('tight') | |
ax.invert_yaxis() | |
ax.hold(False) | |
if __name__ == '__main__': | |
import scipy.io as io | |
import matplotlib.pyplot as plt | |
A = io.loadmat('example.mat')['A'].tocoo() | |
fig = plt.figure() | |
ax = fig.add_subplot(111) | |
fastspy(A, ax) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment