scatter plot with color dependent on variable

4 次查看(过去 30 天)
I want to show all my data like this. In summary;
1. I want to show my data from each group in a different color
2. I want to create error bars like this.
3. I want to set the x and y axes from 1 to 5.
But I don't know how to do it. I'm just learning Matlab.
My codes is below;
scatter (UkWaterS,WaterBeS);
hold on
scatter (UkAG30S,AG30BeS);
hold on
scatter (UkAG40S,AG40BeS);
hold on
scatter (UkAG50S,AG50BeS);
hold on
scatter (UkAG60S,AG60BeS);
hold on
scatter (UkAG70S,AG70BeS);
% Add a colorbar
ColorVariable = 'UkWaterS','UkAG30S', 'UkAG40S','UkAG50S','UkAG60S','UkAG70S';
colorbar
w = c.LineWidth;
c.LineWidth = 1;
  1 个评论
dpb
dpb 2022-6-12
  1. Simply set the color for each in the initial call
2. That will take defining a line for each boundary and plotting those areas with patch
3. xlim([1 5]); ylim([1 5])
There are many examples in graphics in the doc section; explore those. Unfortunately, some graphics packages these days have left MATLAB HG2 far behind in the prepackaged appearance of some of these features like the shaded error bands. Not sure how the image you posted was created, but while it can be done in MATLAB, it's "roll your own" to do so; such a stylistic enhancement is not a prepackaged feature.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Scatter Plots 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by