error with changing color of marker using scatter3

3 views (last 30 days)
I want to create a 3D scatter plot using different colors for each marker, which is information contained in rgb. I keep getting errors, and I can't figure out what is going on!
I checked that the dimensions of Table are 50x4 and that rgb is 50x3 with numbers only 0-1. I tried a test using this "colorvector" and that also did not work, so I don't think it is something to do with the file.
Table = readtable(DataFilePath);
Map = [Table.Var2/360, Table.Var3/100, Table.Var4/100];
rgb = hsv2rgb(Map);
%Colorvector= repmat([0,1,1],height(Table),1);
scatter3(Table,"Var2", "Var3", "Var4", 15, rgb);
It generates the scatter of just Table and the variables with no other modifications , but I can't get any color modifications to work. The error message is "Error using scatter3 (line 57) Invalid parameter/value pair arguments. Error in ScatterplotAttempt1 (line 16) , scatter3(Table,"Var2", "Var3", "Var4",15, rgb );"

Answers (1)

Star Strider
Star Strider on 21 Jan 2022
This is the best I cand o.
See Plot Table Data with Custom Marker Sizes and Colors for a more extensive discussion.
Table = table(rand(10,1),rand(10,1),rand(10,1),rand(10,1))
Table = 10×4 table
Var1 Var2 Var3 Var4 _______ ________ ________ ________ 0.66047 0.73469 0.65788 0.24931 0.21878 0.72915 0.3522 0.87612 0.5944 0.14452 0.058182 0.042146 0.42148 0.75154 0.2069 0.84194 0.25877 0.85524 0.25402 0.099653 0.50772 0.045334 0.75369 0.53293 0.30703 0.14959 0.47609 0.58902 0.24062 0.47135 0.17354 0.50102 0.3063 0.036355 0.50944 0.29015 0.01924 0.49535 0.48377 0.66534
Map = [Table.Var2/360, Table.Var3/100, Table.Var4/100];
rgb = hsv2rgb(Map);
%Colorvector= repmat([0,1,1],height(Table),1);
figure
hs3 = scatter3(Table, 'Var2', 'Var3', 'Var4','filled', 'ColorVariable','Var4');
hs3.SizeData = 15;
colormap(rgb)
colorbar
..

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!