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

조회 수: 7 (최근 30일)
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])

채택된 답변

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!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

제품


릴리스

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by