How to plot data in different colours depending on numeric condition of non plotted data.
2 次查看(过去 30 天)
显示 更早的评论
I am plotting a large number of points and wish to be able to distinguish between them using different colours based on a criteria included within the dataset but not plotted upon the figure.
From my dataset I want to plot all the points in column 8 against all the points in column 6 with the colour of the plotted point dependent on the value in column 17. For example I want to plot the point in red if the value in column 17 is greater than 125, in blue if the value in column 17 is greater than 100 and so on.
I have tried using a for loop but am not having much success. Any help would be much appreciated.
0 个评论
回答(1 个)
Image Analyst
2014-5-25
Use scatter(). It can take different colors for each marker. If you want lines between the markers, call plot() first, then "hold on", then scatter().
4 个评论
Padma Naveena Ganapam
2021-3-23
Perfect:
The above code works for me. I replaced y(k) in the if loop with my third variable.
Thanks a lot!
另请参阅
类别
在 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!