error with changing color of marker using scatter3

조회 수: 4 (최근 30일)
Richa
Richa 2022년 1월 21일
답변: Star Strider 2022년 1월 21일
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 );"

답변 (1개)

Star Strider
Star Strider 2022년 1월 21일
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
..

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by