Display values โ€‹โ€‹from a matrix in a custom color palette (Matlab)

I want to visualize a matrix based on the values โ€‹โ€‹it contains. I have one cell containing 11 matrices, each matrix has 4 columns, which are x, y, z (coordinate) and its values. I want to visualize this value with the location x, y, z and determine my own flower map based on these values, and then display the color bar. I want to use jet as a color map. I want to use blue to describe the maximum value, and red as the minimum value in the color palette. The values โ€‹โ€‹between the maximum and minimum values โ€‹โ€‹are from red to blue.

This is the code I have already tried:

figure; hold on for i=1:length(diameter_lca) L2 = diameter_lca{i}; dl1 = find(L2(:,4) > minimal_lca & L2(:,4)<2);%diameter 0-2 dl2 = find(L2(:,4) >= 2 & L2(:,4) <= maksimal_lca);%diameter>2-maksimal x=L2(:,1); y=L2(:,2); z=L2(:,3); plot3(y(dl1),x(dl1),z(dl1),'*','Color','r'); plot3(y(dl2),x(dl2),z(dl2),'*','Color','b'); end daspect([0.488281 0.488281 0.625000]); view(3); axis tight camlight 

In the above code, I do a visualization of the values โ€‹โ€‹in the 4th column from each matrix, then I made a condition that is, if the value is between 0-2, I gave red, and when it is between the 2-maximum value of the 4th speakers, I gave blue.

Now I need to display each value from the 4th column from each matrix in the colormap jet without any conditions.

+6
source share
1 answer

The easiest way would be to use scatter3 :

 %# make jet colormap from red to blue cmap = flipud(jet(128)); %# plot values figure, scatter3(L(:,1),L(:,2),L(:,3),[],L(:,4),'marker','*') colormap(cmap) colorbar 
+1
source

All Articles