scatter Plot , conditional color variation based on a third value
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I am having difficulty changing the colors in scatter plot if the condition is based on a 3rd value. For example;
f_tot = rand(3,20);
rows = 3;
x = rand(3,20);
y = rand(3,20);
hold on
box on
for p = 1: 1:rows
if f_tot >= 0.8
c = 'red';
else
c = 'blue';
end
scatter(x(:,p),y(:,p),2,c);
end
f_tot decision seems to be completely ignored when executing the condition
4 Kommentare
Nitika Kandhari
am 26 Jun. 2018
Hi, If instead of just 2 colors- red and blue; I need a gradient between blue and red, how would I do that??
I am doing this:
t = 1:3580; %%Time length on the x-axis
for i = 1:1803
if z(i,t) > 0.25
scatter(t, inv(i,t), [], z(i,t), 'filled') %%Plot inverse velocity (inv- 1803*3580 matrix) against time for all data points and color them according to values in the z-matrix (1803*3580)
hold on
end
end
colormap(jet)
If I do no give the if command, my plot looks like the file attached. Essentially, I want to filter out the data points with lower values in z-matrix (blue points). Only the data points having values higher than 0.25 need to be there in the plot. Any ideas??
Nitika Kandhari
am 27 Jun. 2018
I got the answer and I am writing it here in case anyone else needs to do the same.
z(z <= 0.25) = nan;
This replaces the values lower than 0.25 and takes out the noise (blue dots) and filters the data.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!