Discrete Surface Plots (Data visualization)

4 Ansichten (letzte 30 Tage)
Peter Morfe
Peter Morfe am 25 Sep. 2018
Beantwortet: Star Strider am 25 Sep. 2018
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?

Antworten (1)

Star Strider
Star Strider am 25 Sep. 2018
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.

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by