How to draw a matrix sparsity pattern with color code in python? -


i using spy matplotlib.pyplot draw sparsity pattern of csc_matrix scipy.sparse this

>>> import scipy.sparse sprs >>> import matplotlib.pyplot plt >>> matrix=sprs.rand(10,10, density=0.1, format='csc') >>> plt.spy(matrix) >>> plt.show() 

i want same give colors matrix elements according magnitude. there simple way make spy this? if not, there way it?

you use imshow:

d=matrix.todense() plt.imshow(d,interpolation='none',cmap='binary') plt.colorbar() 

gives:

enter image description here


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -