검은 색 표시의 경우 값 1과 흰색 표시의 경우-1을 포함하는 행렬 "위치"의 데이터에서 Matlab에서 다음 플롯을 만드는 가장 간단한 방법은 무엇입니까?
positions=[0 1 0 0 0 0; 0 -1 0 0 0 0; 0 1 0 0 0 0; 1 -1 1 1 -1 0]
됐습니다.
% //Data
positions = [0 1 0 0 0 0; 0 -1 0 0 0 0; 0 1 0 0 0 0; 1 -1 1 1 -1 0];
S = 50; %// circle size. Adjust manually
%// Preparation
[M N] = size(positions);
hold on
%// Plot filled circles
[ip jp] = find(flipud(positions)>0);
plot(jp-.5,ip-.5,'ko','markersize',S,'markerfacecolor','k')
%// Plot empty circles
[in jn] = find(flipud(positions)<0);
plot(jn-.5,in-.5,'ko','markersize',S)
%// Plot grid lines
plot([0 N],(1:M).'*[1 1],'k');
plot((1:N).'*[1 1],[0 M],'k');
%// Set tick labels
set(gca,'xtick',.5:N,'ytick',.5:M)
set(gca,'xticklabel',char((1:N).'+'A'-1),'yticklabel',char((1:M).'+'0'))
%// Set axis size and aspect
axis equal
axis([0 N 0 M])
set(gca,'ticklength',[0 0]) %// no visible ticks
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다