scatter Plot , conditional color variation based on a third value
6 次查看(过去 30 天)
显示 更早的评论
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 个评论
Nitika Kandhari
2018-6-26
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
2018-6-27
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Scatter Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!