How to plot binary matrix as dots?
47 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Dileep Vunnam
am 15 Sep. 2021
Beantwortet: Star Strider
am 15 Sep. 2021
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 Kommentare
Akzeptierte Antwort
Star Strider
am 15 Sep. 2021
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 Kommentare
Weitere Antworten (3)
millercommamatt
am 15 Sep. 2021
FH = figure;
imagesc(yourMatrix);
colormap(FH,[0,0,0;1,1,1]);
0 Kommentare
the cyclist
am 15 Sep. 2021
M = magic(7);
B = M > mean(M);
colormap('gray')
imagesc(B)
axis square
0 Kommentare
Siehe auch
Kategorien
Mehr zu Graphics Object Programming finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!