How do I color a scatterplot?

19 ビュー (過去 30 日間)
Happy_Shovel
Happy_Shovel 2021 年 11 月 18 日
回答済み: Star Strider 2021 年 11 月 18 日
Hi!
I need to scatterplot the arrays x1,x2,y1,y2, in the following way:
scatter([x1;x2],[y1;y2])
how do I make it so that x1 and y1 have a different color than x2 and y2?
Thanks

採用された回答

Star Strider
Star Strider 2021 年 11 月 18 日
Try this —
x1 = 1:10;
y1 = rand(size(x1));
x2 = 5:15;
y2 = rand(size(x2))+0.5;
figure
scatter(x1, y1, 50, 'dr', 'filled')
hold on
scatter(x2, y2, 50, 'sg', 'filled')
hold off
grid
legend('(x_1, y_1)','(x_2, y_2)', 'Location','best')
Experiment!
.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInterpolation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by