# removing some data in a 4d plot

1 view (last 30 days)
Hamid Basiri on 12 May 2022
Answered: Chunru on 12 May 2022
Hi every one,
I have a 4d plot and want to make some limitation for the 4th dimention of my graph. For example if the value is higher than 0.9 plot otherwise ignore that point. I am using scatter3(x,y,z,10,teta,'filled') and I attached the sample input file.
I did the limitation using teta(teta>0.9)=[];
And the error I faced is:
Error using scatter3
Color must be one RGB triplet, an m-by-3 matrix of RGB triplets with one color per scatter point, or an m-by-1 vector with one value
per scatter point.
cla
x = 4dplot(:,1);
y = 4dplot(:,2);
z = 4dplot(:,3);
teta = 4dplot(:,4);
scatter3(x,y,z,10,teta,'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

DGM on 12 May 2022
You have to apply the same operation to all of the vectors.
x = X4dplot(:,1);
y = X4dplot(:,2);
z = X4dplot(:,3);
teta = X4dplot(:,4);
goodpts = teta <= 0.9;
scatter3(x(goodpts),y(goodpts),z(goodpts),10,teta(goodpts),'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

Chunru on 12 May 2022
% x = 4dplot(:,1); % wrong: variable names canno start with number
x = data(:,1);
y = data(:,2);
z = data(:,3);
teta = data(:,4);
idx = teta >= 0.9;
scatter3(x(idx),y(idx),z(idx),10,teta(idx),'filled')
ax = gca;
ax.XDir = 'reverse';
view(-31,14)
cb = colorbar;

R2022a

### Community Treasure Hunt

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

Start Hunting!

Translated by