3D Scatter plot color map issues
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Harris Chan
le 22 Juin 2020
Modifié(e) : Adam Danz
le 22 Juin 2020
Hi guys,
I am trying to plot a 3D scatter diagram using a .csv file. However, I have faced some difficulties while I was trying to arrange the color mapping of the diagram. Attached below is the .csv file and the current plot of the code. I am hoping the range of the color legend will be based on the z-component of the data, similar to the second images below.
Your help will be much apprecated.


clc; clear all; close all;
data= importdata('ScanData.csv');
x=data(:,1);
y=data(:,2);
z=data(:,3);
%scatter3(x,y,z);
markerColors = jet(length(z));
colorbar
scatter3(x, y, z, 1, markerColors, 'filled')
grid on
xlabel('x');
ylabel('y');
zlabel('z');
title('3D Plot')
0 commentaires
Réponse acceptée
Adam Danz
le 22 Juin 2020
Modifié(e) : Adam Danz
le 22 Juin 2020
You have to assign the colormap to your axes.
set(gca, 'Colormap', markerColors)
The axes colormap is a separate property than the colors assigned to a scatter plot. Then colorbar references the axes' colormap and is unrelated to the colors used in the scatter objects.
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!