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

6 visualizaciones (últimos 30 días)
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])

Respuesta aceptada

Star Strider
Star Strider el 26 de Mzo. de 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 comentarios
Elizabeth Lees
Elizabeth Lees el 28 de Mzo. de 2021
lsline function works brilliantly! thank you so much all for your help!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Scatter Plots en Help Center y File Exchange.

Productos


Versión

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by