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.