Blank figure when using spy to display a large matrix
7 views (last 30 days)
Show older comments
Shelby Becker
on 13 Sep 2022
Edited: Walter Roberson
on 14 Sep 2022
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.
0 Comments
Accepted Answer
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
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')
but since you are getting markers for low resolution, the problem would have to be something different.
More Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!