Effacer les filtres
Effacer les filtres

display errorbar on each point in the curve matlab code

3 vues (au cours des 30 derniers jours)
bassant tolba
bassant tolba le 13 Mai 2023
Commenté : bassant tolba le 14 Mai 2023
I have data point of two curves in one graph as follows
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ] ;
I want to display "errorbar" on each point for each curve with legend in one graph.
Please can anyone help me ?
Thanks in advance.
  3 commentaires
Saurabh Patel
Saurabh Patel le 13 Mai 2023
% User Data Collection
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ];
% define the error for eact errorbar
err_y1=30*ones(size(y1));
err_y2=25*ones(size(y2));
% Two Y-axis on same Plot
yyaxis left
errorbar(x,y1,err_y1,'LineWidth',2)
ylabel('Data of Y1');
xlabel('X-axis');
yyaxis right
errorbar(x,y2,err_y2,'LineWidth',2)
ylabel('Data of Y2');
% Insert Legend
labels={'Data of Y1','Data of Y2'};
legend(labels,'Location','northwest','Orientation','vertical');
bassant tolba
bassant tolba le 14 Mai 2023
Thank you very much for your answer.

Connectez-vous pour commenter.

Réponse acceptée

Saurabh Patel
Saurabh Patel le 13 Mai 2023
% User Data Collection
x=[2,4,6,8,10];
y1=[58.87 168 366 670.48 715];
y2=[51 147 327 525 645.69 ];
% define the error for eact errorbar
err_y1=30*ones(size(y1));
err_y2=25*ones(size(y2));
% Two Y-axis on same Plot
yyaxis left
errorbar(x,y1,err_y1,'LineWidth',2)
ylabel('Data of Y1');
xlabel('X-axis');
yyaxis right
errorbar(x,y2,err_y2,'LineWidth',2)
ylabel('Data of Y2');
% Insert Legend
labels={'Data of Y1','Data of Y2'};
legend(labels,'Location','northwest','Orientation','vertical');

Plus de réponses (0)

Catégories

En savoir plus sur Errorbars dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by