Spy function for large sparse matrices


I tried

julia> using Plots
julia> spy(A)

for a rather large sparse matrix, and spy just hangs there for too long for it to be useful to me… MATLAB’s spy is quite fast in comparison. I’m guessing Julia’s spy plot is not binning the data? But how can I get that info since I can’t find the documentation:

help?> spy
search: spy spy! speye display Display displaysize displayable redisplay popdisplay isempty TextDisplay supertype pushdisplay

  No documentation found.

  Plots.spy is a Function.

  # 1 method for generic function "spy":
  spy(args...; kw...) in Plots at /Users/XXXXXX/.julia/v0.6/RecipesBase/src/RecipesBase.jl:367

What am I doing wrong?


Is it only slow the first time? That’s a known Plots.jl problem. If it’s more than just the first time, then it’s something else.


It is that slow that I don’t know how long it is gonna take because I cannot afford to wait… In MATLAB, spy is a convenient way to check a sparsity pattern, and takes almost no time to plot. It seems to me spy should never be slow, right?

using UnicodePlots


Plots.jl has a slow first plot time because that’s when it sets up the backend and this is orthogonal to spy. You still haven’t mentioned whether it’s just the first plot time or not.


I’m sorry, it is not the first use of spy, but it is the first use on a matrix of that size.


It also depends on the backend you are using, Gadlfy’s spy is very slow for example. Maybe try GR. Sometimes I just write a png, which is often faster that plotting.

using UnicodePlots

Thank you, that seems to be a good solution :slight_smile:


I am I am properly using the GR backend, but

julia> using Plots
julia> gr()
julia> spy(A)

did not work for me (still very slow, actually had to close the terminal window as CTRL-C could not stop the process).