How to plot binary matrix as dots?
56 次查看(过去 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.
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!