How can I get use property colormap from heatmap to color the data points of (x,y) based on the values from r?

6 ビュー (過去 30 日間)
How can I use colormap(hot) to color the data points of (x,y) based on the values from r?
x = 150:50:5000;
y = -x+2000/5;
a = 30;
b = 0;
r = a+(b-a)*rand(1.length(x));
allData = [x;y;r];
figure;
heatmap(x,y, 'colormap', hot)
xlim([min(x) max(x)])
ylim([min(y) max(y)])

採用された回答

Voss
Voss 2025 年 4 月 9 日
編集済み: Voss 2025 年 4 月 9 日
x = 150:50:5000;
y = -x+2000/5;
a = 30;
b = 0;
% r = a+(b-a)*rand(1.length(x));
r = a+(b-a)*rand(1,length(x));
figure()
scatter(x,y,[],r,'.')
colormap('hot') % or 'jet', or wtf you want
colorbar() % optional (once requested; no longer requested)
axis('tight')
  1 件のコメント
Rookie Programmer
Rookie Programmer 2025 年 4 月 9 日
編集済み: Rookie Programmer 2025 年 4 月 9 日
Thank you Voss. Since I posted the question I found an alternative method to complete the task using the plotting function heatmap. I think your method works best.
-MB

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeColor and Styling についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by