Displaying error bars on scatter plot (Bland-Altman plot)
Afficher commentaires plus anciens
Hello all,
I have a scatter plot (Bland-Altman plot) showing the agreement between two sensors measuring knee angle for 1 gait cycle. I would like to plot the error bars in the y direction but I am having issues with this.
I want the initial HS one colour and then the final index which is HS another colour. I have plotted the mean and +-2SD to indicate the spread of the data.
I have then tried to plot the error bars which have not worked, please would you be able to advise how to do this.

Please see code below:
%% Average Bland-Altman plot
% Plot mean difference line
figure;
first_index = 1;
last_index = numel(mean_data);
scatter(mean_data(first_index), diff_data(first_index), 'filled', 'MarkerFaceColor', 'green');
hold on
scatter(mean_data(last_index), diff_data(last_index), 'filled', 'MarkerFaceColor', 'red');
hold on
scatter(mean_data(2:100), diff_data(2:100), 'filled','MarkerFaceColor', 'black');
hold on;
%+- 2SD
plot([-10 70], [mean_diff + 2*std_diff, mean_diff + 2*std_diff], 'r--');
plot([-10 70], [mean_diff - 2*std_diff, mean_diff - 2*std_diff], 'r--');
%mean diff line
plot([-10 70], [mean_diff, mean_diff], 'k-', 'LineWidth', 1);
%calculate error bars
error_bar_y = errorbar(mean_data,diff_data, 'vertical', 'LineStyle', 'none');
set(error_bar_y, 'color', 'k', 'LineWidth', 2)
legend({'HS_1', 'HS_2', 'Average gait cycle Data', '+ 2 SD', '- 2 SD', 'Mean Difference'});
hold on
xlim([-10 70])
ylim([-10 10])
xlabel('Mean($\o - \bar{\o}$) (deg)', 'Interpreter','Latex')
ylabel('Difference (deg)')
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Bar Plots dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

