# Plot in matlab, multiple plots in one figure.

2 ビュー (過去 30 日間)
Ibrahim 2015 年 1 月 15 日
コメント済み: Image Analyst 2015 年 1 月 15 日
Hello! I need some help with the following:
Imagine a matrix: N x 3. (an example:
if true
% code
end
___x___ |___y___|__Z__|
1 | 2 | 1 |
2 | 3 | 2 |
3 | 2 | 3 |
4 | 2 | 4 |
2 | 3 | 1 |
7 | 4 | 2 |
8 | 2 | 3 |
8 | 2 | 4 |
3 | 4 | 1 |
And the matrix is defined by a data list.
THE QUESTION: we want to plot the (x,y) values, for each Z value in the same coordinate system. Also we need to make it possible to see a difference between them.
I figured out the how to change the color, marking etc.
But i DO NOT know how to plot for Z = 1, Z = 2. ?
if true
% code
end
I tried something like:
for DATA(:,3)==1 %(the datalist called DATA)
plot(x,y,'ro')
hold on
for DATA(:,3)==2; plot(x,y,'dk') hold on etc.
ib
##### 1 件のコメント-1 件の古いコメントを表示-1 件の古いコメントを非表示
Image Analyst 2015 年 1 月 15 日
Are the Z all definitely integers, or can they have fractional values (in which case you'll need to bin them with hist())? And what is the "data list"? Is that what you somehow used to create the matrix of x,y,z values? Does it matter what it is, or can we just take the x,y,z matrix as a given (a starting point)?

サインインしてコメントする。

### 採用された回答

Iain 2015 年 1 月 15 日
x_for_z1 = matrix(matrix(:,3)==1,1);
y_for_z1 = matrix(matrix(:,3)==1,2);
plot(x_for_z1,y_for_z1,'r') hold on etc etc..
##### 2 件のコメントなしを表示なしを非表示
Ibrahim 2015 年 1 月 15 日
Thanks!!!
It is B-E-A-U-T-I-F-U-L! :-D
Image Analyst 2015 年 1 月 15 日
Note: this will not work if Z has fractional values like 2.0001 and 3.9999. See the FAQ. It will work for integers though. However you may want to do it for all Z in which case you'll want to call unique() and put lain's code into a for loop.

サインインしてコメントする。

### カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by