Discrete Surface Plots (Data visualization)

조회 수: 4 (최근 30일)
Peter Morfe
Peter Morfe 2018년 9월 25일
답변: Star Strider 2018년 9월 25일
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?

답변 (1개)

Star Strider
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.

카테고리

Help CenterFile Exchange에서 Surface and Mesh Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by