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 Center および File ExchangeSurface 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