フィルターのクリア

How to use colormap/colorbar for plots

7 ビュー (過去 30 日間)
Fernanda
Fernanda 2022 年 10 月 20 日
コメント済み: Adam Danz 2022 年 10 月 21 日
Hey everyone, when I plot my matrixs it works but now I want to add some color. I want the colors at each point to depend on the x and y coordinate so x+y. I hope that makes any sense. So the higher that x+y value is for a point the higher the color intensity is.
x = [0.5:2:18] ;
y = [30:10:100] ;
[a,b] = meshgrid(x,y);
plot(a,b,'ko',a, a+b,'ko');
colormap
ans = 256×3
0.2422 0.1504 0.6603 0.2444 0.1534 0.6728 0.2464 0.1569 0.6847 0.2484 0.1607 0.6961 0.2503 0.1648 0.7071 0.2522 0.1689 0.7179 0.2540 0.1732 0.7286 0.2558 0.1773 0.7393 0.2576 0.1814 0.7501 0.2594 0.1854 0.7610
colorbar

回答 (1 件)

Adam Danz
Adam Danz 2022 年 10 月 20 日
編集済み: Adam Danz 2022 年 10 月 20 日
It sounds like you're looking for
x = [0.5:2:18] ;
y = [30:10:100];
[a,b] = meshgrid(x,y);
c = a(:)+b(:);
scatter(a(:),c,80,c,'filled')
colorbar
  2 件のコメント
Fernanda
Fernanda 2022 年 10 月 20 日
I also want to plot a and a+b on the same graph, how should I do that?
Adam Danz
Adam Danz 2022 年 10 月 21 日
Plot one, then hold on, then plot the second.

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

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by