Colour legend for scatter plot

15 ビュー (過去 30 日間)
Adam Fitchett
Adam Fitchett 2019 年 11 月 20 日
コメント済み: darova 2019 年 11 月 20 日
I created a 2D scatter plot with the vectors X, Y and Z and the following code
scatter(X,Y,50,Z)
So that I would have X and Y plotted against one another, and Z would be represented as the graded colour of each marker. It worked fine, but I need a legend that shows the range of Z values represented by the range of marker colours. How do I make this?

回答 (1 件)

Ruger28
Ruger28 2019 年 11 月 20 日
編集済み: Ruger28 2019 年 11 月 20 日
x = [1:50]; % fake x data
y = [1:50]; % fake y data
z = [1:50]; % "intensity"
scatter(x,y,50,z,'filled');
cb = colorbar; % creates the colorbar on side
% use caxis to change range on colorbar
caxis([10,30]); % low end is 10, high end is 30
  1 件のコメント
darova
darova 2019 年 11 月 20 日
It works. I have voted for this answer

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

カテゴリ

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

製品


リリース

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by