MATLAB 4D color plot
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am an amateur user of MATLAB and I would like to have a 4D color plot which the color represent the forth dimension. I try to use scatter3 as follow:
fid = fopen('abc.dat','r');
datacell = textscan(fid, '%f%f%f%f');
fclose(fid);
all_data = cell2mat(datacell); %converted into a matrix
boxx = all_data(:,1);
boxy = all_data(:,2);
boxz = all_data(:,3);
disden = all_data(:,4); %color depends on the value of disden
scatter3(boxx,boxy,boxz,400,disden,'filled')
xlabel('Box x')
ylabel('Box y')
zlabel('Box z')
cb = colorbar; % create the colorbar
set(get(cb,'title'),'string','Dislocation Density(m^{-2})'); % label colobar
Although it works but I want the whole space to be filled up by cubes instead of spots in the above case. In the above case only spots are used so even their size can be set they still cannot fill up the space. All my x,y,z values are integers, can I use cube with size 1x1x1 with colors defined by the forth dimension so that the whole space can be filled up?
Another problem is the label of the color bar is too close with the numbers shown in colorbar and they overlap. Can I set the position of the bar label so that it is a little bit further away?
Many thanks.
0 Kommentare
Antworten (1)
Walter Roberson
am 5 Okt. 2015
scatter3() cannot create cubes. You can create cubes using patch().
Caution: when you fill up the space with cubes, you will not be able to see "into" the space, except to the extent that you use AlphaData to make surfaces more or less transparent.
When you have solid 3D (plus value) data then you should consider a voxel viewer, or slice() or isosurface()
2 Kommentare
Walter Roberson
am 5 Okt. 2015
patch() has a calling sequence which is not the same as scatter3(). See http://www.mathworks.com/help/matlab/ref/patch.html
In particular in order to create the cubes like you want, you will want to use the Faces and Vertices form, along with passing some of the other properties which you can find described at http://www.mathworks.com/help/matlab/ref/patch-properties.html
You will need to decide whether you want to build interior cubes or if you just want to define a bunch of rectangular faces. Either way watch out for defining the vertices in a consistent order so that lighting can be done correctly.
Siehe auch
Kategorien
Mehr zu Surface and Mesh Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!