フィルターのクリア

How to plot two columns of a repeated value column from the same matrix?

1 回表示 (過去 30 日間)
Philippe Corner
Philippe Corner 2020 年 12 月 2 日
回答済み: David Hill 2020 年 12 月 2 日
if A is a 10x4 matrix with some repeated values along A(:,1) like:
A=[1 10 13 31
1 15 33 22
1 43 3 12
1 3 54 12
2 45 34 13
2 44 31 12
2 32 35 11
3 34 13 31
3 34 34 12
4 35 23 43];
I want to plot scatter(A(:,4),A(:,3)) with the same dot color for every value of A(:,1) that is repeated. For instance a manual plot of A would be:
scatter(A(1:4,4),A(1:4,3),'filled','r')
hold on
scatter(A(5:7,4),A(5:7,3),'filled','b')
hold on
scatter(A(8:9,4),A(8:9,3),'filled','k')
hold on
scatter(A(10,4),A(10,3),'filled','g')
Which plots
I used manually the colors red, blue, black and green for the first 4 repeated values. But to analize a big dataset, i would like to plot the scatter using a colorbar for the increasing A(:,1) repeated values.

採用された回答

David Hill
David Hill 2020 年 12 月 2 日
sz=25;
scatter(A(:,4),A(:,3),sz,A(:,1),'filled');

その他の回答 (0 件)

カテゴリ

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