How to plot data in different colours depending on numeric condition of non plotted data.

2 ビュー (過去 30 日間)
Robert
Robert 2014 年 5 月 25 日
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.

回答 (1 件)

Image Analyst
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 件のコメント
Robert
Robert 2014 年 5 月 26 日
The issue I have is that the condition I am using is not part of the plotted data. The condition to determine the colour of the points comes from a variable 'z' within the data set but only x and y are being plotted.
I have found a way to make it work by splitting up the data set into smaller individual data sets based on the criteria and then plotting them all onto the same figure, however I am keen to find a less messy way to do this and so that I can still interact with the data without having to call back information from every smaller data set.
Padma Naveena Ganapam
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 ExchangeScatter Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by