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

6 vues (au cours des 30 derniers jours)
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 commentaire
Elizabeth Lees
Elizabeth Lees le 27 Mar 2021
Still looking for a solution to adding a line of best fit to the scatter() function

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 26 Mar 2021
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 commentaires
Elizabeth Lees
Elizabeth Lees le 28 Mar 2021
lsline function works brilliantly! thank you so much all for your help!
Star Strider
Star Strider le 28 Mar 2021
As always, my pleasure!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by