フィルターのクリア

How can I set one lsline using gscatter?

29 ビュー (過去 30 日間)
Jose Rego Terol
Jose Rego Terol 2020 年 9 月 2 日
コメント済み: Jose Rego Terol 2020 年 9 月 2 日
Hi,
So, I got 4 groups. By using gscatter I can colour each group. Now I want one lsline but I got 4 differnet lsline, one per group.
group=[zeros(str2num(answer{1,1}),1);1+zeros(str2num(answer{2,1}),1);...
2+zeros(str2num(answer{3,1}),1);3+zeros(str2num(answer{4,1}),1)];
group=string(group);
group=strrep(group, '0', 'Wt');
group=strrep(group, '1', 'Cpx II Ko');
group=strrep(group, '2', 'Cpx II Ko + Cpx I');
group=strrep(group, '3', 'Cpx II Ko + Cpx II');
h =gscatter(x,y,group);
hold on
lh = lsline;
This is my code. By doing this I got 4 different lslines. I want a single lsline made by all the values from x and y.
I've also tried this:
figure(1)
scatter(x_ko,y_ko,25,'LineWidth',2);
hold on
scatter(x_wt,y_wt,25,'LineWidth',2);
hold on
scatter(x_kowt,y_kowt,25,'LineWidth',2);
hold on
scatter(x_ko2,y_ko2,25,'LineWidth',2);
hold on
lh = lsline;
Same result, 4 lsline. I want one lsline for
This is the plot. 4 lsline. One each group. I want one lsline from all the dots.
Alternatively, I can use scatter(x,y) but then I do not know how to paint the dots by groups.

採用された回答

Adam Danz
Adam Danz 2020 年 9 月 2 日
編集済み: Adam Danz 2020 年 9 月 2 日
Use coeffs = polyfit(x,y,1) to compute the regression line for all of the data and then refline(coeffs) to plot the regression line.
  1 件のコメント
Jose Rego Terol
Jose Rego Terol 2020 年 9 月 2 日
Thanks! I didn't realize about this option.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeWorkspace Variables and MAT-Files についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by