Blank figure when using spy to display a large matrix

조회 수: 7 (최근 30일)
Shelby Becker
Shelby Becker 2022년 9월 13일
편집: Walter Roberson 2022년 9월 14일
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.

채택된 답변

Walter Roberson
Walter Roberson 2022년 9월 13일
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
Walter Roberson
Walter Roberson 2022년 9월 14일
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 2022년 9월 14일
편집: Walter Roberson 2022년 9월 14일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Images에 대해 자세히 알아보기

태그

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by