Adding text from calculated functions and line of best fit to scatter plot

7 ビュー (過去 30 日間)
Elizabeth Lees
Elizabeth Lees 2021 年 3 月 26 日
コメント済み: Star Strider 2021 年 3 月 28 日
I have calculated three statistic values for observed vs simulated data. I want to add these defined output values (i.e. the cor_Manual_Urbano, bias_da_Manoel_Urbano, NASH_Manoel_Urbano) to the scatter plot of oberserved vs simulated. There is the additional problem that the output result for cor_Manual_Urbano produces a matrix but I only want to display the correlation value between the two variables. I also want to add a line of best fit to the scatter plot. Here is my code so far:
%pearsons%
cor_Manoel_Urbano = corrcoef(combined_data.Observed_Manoel_Urbano,combined_data.Simulated_Manoel_Urbano, 'Rows', 'pairwise')
%bias%
just_Manoel_Urbano = combined_data(:, [11,22]);
cleaned_Manoel_Urbano = rmmissing(just_Manoel_Urbano);
observedmean_Manoel_Urbano = mean(cleaned_Manoel_Urbano.Observed_Manoel_Urbano);
simulatedmean_Manoel_Urbano = mean(cleaned_Manoel_Urbano.Simulated_Manoel_Urbano);
bias_da_Manoel_Urbano = 100*((observedmean_Manoel_Urbano-simulatedmean_Manoel_Urbano)/observedmean_Manoel_Urbano)
%NASH%
DATA_NASH_Manoel_Urbano = [combined_data.Observed_Manoel_Urbano,combined_data.Simulated_Manoel_Urbano];
DATA_NASH_Manoel_Urbano(any(isnan(DATA_NASH_Manoel_Urbano), 2), :) = [];
NASH_Manoel_Urbano = NSE(DATA_NASH_Manoel_Urbano(:,1), DATA_NASH_Manoel_Urbano(:,2))
%scatter%
figure22 = figure('Name','Scatter Manoel Urbano','Color',[1 1 1]);
scatter(cleaned_Manoel_Urbano.Observed_Manoel_Urbano, cleaned_Manoel_Urbano.Simulated_Manoel_Urbano, 'k')
xlabel('Observed','FontName','Calibri','FontSize',12)
ylabel('Simulated', 'FontName','Calibri','FontSize',12)
title('Manoel Urbano','FontName','Calibri','FontSize',14);
set(gcf,'Position',[100 100 400 400])
  1 件のコメント
Elizabeth Lees
Elizabeth Lees 2021 年 3 月 27 日
Still looking for a solution to adding a line of best fit to the scatter() function

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

採用された回答

Star Strider
Star Strider 2021 年 3 月 26 日
To display the information on the plot, use the text function.
The sprintf or compose functions can also be helpful, depending on what you want to do.
  10 件のコメント
Elizabeth Lees
Elizabeth Lees 2021 年 3 月 28 日
lsline function works brilliantly! thank you so much all for your help!
Star Strider
Star Strider 2021 年 3 月 28 日
As always, my pleasure!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by