plotting 2 time series with errorbars along double y axis
조회 수: 1 (최근 30일)
이전 댓글 표시
I have 2 time series data with standard eror rof mean too i.e.
errorbar(t,y1,erb-y1) and errorbar(t,y2,erb-y2)
This is to be plotted like the figure, I tried the code but cannot activate secondary y axis.
My Matlab Version is 2015
I need something like the enclosed figure
I tried something but didnt work out
errorbar(A(:,4),A(:,2), A(:,3),'Linestyle',':','LineWidth',1.5,'Color',[0 0 0])
axes1 = axes('Position',[0.131398601398601 0.11 0.775 0.815],...
'YTickLabel',{'','0','5','10','15','20','25'},...
'YTick',[-5 0 5 10 15 20 25]);
hold(axes1,'on');
% Activate the left side of the axes
% % yyaxis(axes1,'left');
% Create multiple error bars using matrix input to errorbar
errorbar(B(:,4),B(:,2),B(:,3),'LineWidth',1.5,'Color',[0 0 0]);
% Set the remaining axes properties
set(axes1,'YColor',[0 0 0],'YDir','normal');
ylim(axes1,[-1 30]);
댓글 수: 0
답변 (1개)
Scott MacKenzie
2021년 10월 17일
I think this is more-or-less what you are after, based on the figure posted:
% test data
x = 1:10;
A = [2 8 6 11 18 19 16 22 24 25];
B = [27 22 39 42 35 42 45 40 35 30];
Ae = 1+2*rand(1,10);
Be = 1+2*rand(1,10);
yyaxis left;
errorbar(x, A, Ae, Ae, 'color', 'b');
ylabel('A');
xlabel('Time');
yyaxis right;
errorbar(x, B, Be, Be, 'color', 'r');
ylabel('B');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!