Scatter plot customization question

1 回表示 (過去 30 日間)
Kevin Pham
Kevin Pham 2021 年 3 月 3 日
回答済み: Cris LaPierre 2021 年 3 月 4 日
Hello,
So I have a scatterplot of the following vectors.
flipper_length = [2,3,4,5,6];
body_mass = [12,24,56,78,90];
But now I want to incorporate a third vector into it.
species = [A,B,C,C,B];
When performing the following:
scatter(flipper_length,body_mass,species)
It gives me the output I want but it's not very cosmetically pleasing. It just shows the scatterplot but differentiating each element in species apparently defaults to 3 unique looking circles with the same color. Is there any way I can make them the standard scatterplot circles but each unique element in the species vector a different color?
Thanks!

回答 (1 件)

Cris LaPierre
Cris LaPierre 2021 年 3 月 4 日
Your third input is specifying the marker size.
Perhps a better choice might be a group scatter plot. Here, your third input specifies the groups.
flipper_length = [2,3,4,5,6];
body_mass = [12,24,56,78,90];
species = ["A","B","C","C","B"]';
gscatter(flipper_length,body_mass,species)

カテゴリ

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