How to plot binary matrix as dots?
조회 수: 48 (최근 30일)
이전 댓글 표시
I have a Matrix with ones and zeroes. How to plots the matrix with zeroes as black spot and ones as whote dots as shown in figure below.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/739834/image.png)
댓글 수: 0
채택된 답변
Star Strider
2021년 9월 15일
Try this —
M = randi([0 1],25)>0; % Logical Matrix
[r,c] = find(M);
figure
scatter(c, r, 75, 'sw', 'filled')
set(gca, 'Color','k', 'YDir','reverse')
axis([0 size(M,1)+1 0 size(M,2)+1])
% axis('equal')
The spy function works for this, however it does not have the ability to fill the markers, so I went with scatter instead.
figure
spy(M,'sw');
set(gca, 'Color','k')
hs.MarkerFaceColor = 'w';
Experiment to get the result you want.
.
댓글 수: 0
추가 답변 (3개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Object Programming에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!