Blank figure when using spy to display a large matrix

7 views (last 30 days)
I am trying to display a binary matrix of size 400 x 500 using the spy command. The steps I am using to do this are:
>> A = rand(400, 500); %Creates a random 400x500 matrix with each entry in [0,1]
>> A = round(A,0); % Replaces A with the result of rounding each entry to the nearest integer, producing a random matrix of zeros and ones
>> spy(A) % Creates a spy image of A in a plot window
When I copy the provided commands, my figure appears to be blank in the plot window. Testing the spy command with smaller matrices (for example a 3x3 matrix) it shows the image as expected. The issue appears to be related to the large size of the matrix I want to show, but I am not sure how to fix this issue. There is no error code, just a blank figure. I am using Matlab version 2022a.

Accepted Answer

Walter Roberson
Walter Roberson on 13 Sep 2022
Works for me.
A = round(rand(400, 500));
spy(A)
I suggest you
which -all spy
to check whether you are using a third-party spy() function.
spy() is implemented as plot() with a Marker. Markers take up a fixed amount of output no matter what the zoom level, so if you have a large array in a small window you will end up with a dense output.
This is unlike displaying an image: if you have an image that is too large for the output then the individual pixels can get merged, so you can end up with a situation where a set pixel can get averaged out to effective blank because enough empty image pixels nearby it got merged together to get a low-value image pixel result. But spy() does not use that technique, so all points will always be displayed (but might not be distinguishable if the window is too small.)
There is one possibility that I can think of. Historically, some AMD graphics card drivers were faulty and would not necessarily display properly. Also, some very old Intel HD graphics card drivers had problems.
  3 Comments
Walter Roberson
Walter Roberson on 14 Sep 2022
MacOS automatically updates the graphics drivers. The Intel HD 5000 cards was not one of the cards that tends to have a problem (the HD 100 to HD 1000 are very out of date though.)
Those which results look correct for spy.
Could you confirm that this code
rng(12345);
data = round(rand(400,500));
spy(data)
is giving you a blank plot ?
If you were not getting plots even for low resolution, I might suggest looking at
get(groot, 'DefaultLineMarkeredgecolor')
ans = 'auto'
but since you are getting markers for low resolution, the problem would have to be something different.
Shelby Becker
Shelby Becker on 14 Sep 2022
Edited: Walter Roberson on 14 Sep 2022
I just tested it, and:
rng(12345);
data = round(rand(400,500));
spy(data)
Is also giving a blank plot. Running
get(groot, 'DefaultLineMarkeredgecolor')
did return 'auto' as expected. I was able to log into my Matlab account on a newer Macbook Pro, and the spy command worked as expected. This leads me to believe the problem is with my computer itself, rather than my Matlab account. I am not sure what the problem is, but it doesn't seem like a result of a Matlab setting or issue.

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Products


Release

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!