Discrete Surface Plots (Data visualization)
조회 수: 4 (최근 30일)
이전 댓글 표시
I am working on visualizing discrete random surfaces (e.g. Ising model). What I would like to be able to do is take the random data (which is an N x N array of 0s and 1s) and plot it in a 2D grid of squares. The squares corresponding to 0s would be blue, the squares corresponding to 1s would be red, let's say. (The end product should look like a "random patchwork quilt," effectively.) Is there a function in matlab ready made for this?
댓글 수: 0
답변 (1개)
Star Strider
2018년 9월 25일
I am not certain what you want.
Hereare two options, the first simply a ‘patchwork’ plane, and the second a 3D bar3 plot:
M = randi([0 1], 7); % Create Matrix
cmap = [1 0 0; 0 0 1]; % Define Red-Blue ‘colormap’
figure
imagesc(M)
colormap(flipud(cmap))
figure
h = bar3(M);
colormap(cmap)
for k1 = 1:numel(h)
q = h(k1).ZData;
h(k1).CData = ones(size(q)).*(q==0);
h(k1).EdgeColor = [1 1 1]*0.8;
h(k1).CData(:,1) = 0;
end
axis equal
You will likely need to experiment to get the result you want with your data.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!