Hello, everyone. I have two input data (mean and standard deviation). I would like to create a graph similar to this one:
I have not found a suitable code. I had thought of an "errorbar". Does anyone know how to draw this graph?

 채택된 답변

Voss
Voss 2022년 3월 20일
편집: Voss 2022년 3월 20일
% First, I create a random matrix x, and calculate
% the mean (x_mu) and standard deviation (x_std) of
% each column
% *You have this already*
N = 10;
x = randn(100,N);
x_mu = mean(x,1);
x_std = std(x,0,1);
% Now make the plot:
figure();
% mean +/- std:
x_max = x_mu+x_std;
x_min = x_mu-x_std;
% XData and YData of the error bar lines:
xd = (1:N)+([-0.1; 0.1; 0; 0; -0.1; 0.1; NaN]);
yd = [x_max([1 1 1],:); x_min([1 1 1],:); NaN(1,N)];
% create the error bar lines:
line(xd(:),yd(:),'Color','k');
% create a line for marking the mean of each column of x:
line(1:N,x_mu, ...
'Marker','s', ...
'MarkerSize',12, ...
'LineStyle','none', ...
'Color','k', ...
'MarkerFaceColor','w');
% set the grid and xlim:
grid on
xlim([0 N+1]);

댓글 수: 4

Alberto Acri
Alberto Acri 2022년 3월 20일
OK, that's what I wanted!
But in my case it appears as follows (as if the background inside the square is transparent and not white):
p.s. Is it possible to enlarge the square?
Voss
Voss 2022년 3월 20일
I edited the answer shortly after posting it to change the square background to white (and edited again now to increase the size of the square).
Please check the latest version of the answer.
Alberto Acri
Alberto Acri 2022년 3월 20일
ok thanks a lot
Voss
Voss 2022년 3월 20일
You're welcome!

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Errorbars에 대해 자세히 알아보기

제품

릴리스

R2021b

질문:

2022년 3월 20일

댓글:

2022년 3월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by