matlab has function spy visualizing sparsity patterns of graph adjacency matrices.
unfortunately not display points taking account magnitude of values in matrix. uses single color same intensity display entries.
i wish display same spy plot points "color-coded" in heatmap indicate magnitude of entries. how can that?
if matrix not large try view image using imagesc()
. (well use quite large matrices well, pixels become small.)
here example of 20
random points in 100x100
matrix, using colormap hot
:
n = 100; n = 20; x = randi(n,1,n); y = randi(n,1,n); z = randi(n,1,n); data = sparse(x,y,z); imagesc(data) axis square colormap('hot')
this resulting image.
this can compared plot using spy(data)
markers bit larger.
if white background desired easy way achieve flip colormap:
figure imagesc(data) axis square cmap = flipud(colormap('hot')); colormap(cmap)
hack solution redefining spy()
googling bit found thread @ matlab central:
there solution suggested redefines spy()
. it's worth noting (further down in thread) solution can cause matlab crash larger matrices.