Grouped error bars change position after saving figure
이전 댓글 표시
I have a grouped bar graph with error bars (3 groups, 5 bars each, 15 bars and error bars total). When the figure is first created, the plot looks fine, but when I save (using file>saveas in the figure window) and repoen the figure, the error bars move from being centered on their respective bars (correct) to being centered on each group (incorrect). I've scowered the figure and errorbar property lists for a setting that might prevent this with no luck and there doesn't seem to be any other posts here that address this issue either.
Code
barHeights = [0.954, 0.666, 0.604, 0.842, 0.662;...
0.021, 0.280, 0.259, 0.145, 0.212;...
0.027, 0.075, 0.100, 0.022, 0.084];
barErrors = [0.023, 0.057, 0.091, 0.056, 0.081;...
0.007, 0.046, 0.080, 0.053, 0.091;...
0.018, 0.029, 0.029, 0.016, 0.034];
[nGroups,nBars] = size(barHeights);
groupNames = categorical("Group" + string(1:nGroups));
barNames = "Bar" + string(1:nBars);
figure;
hold on
b = bar(groupNames,barHeights,'FaceColor','flat');
title("Title");
xlabel("xlabel");
ylabel("ylabel");
grid on;
x = reshape([b.XEndPoints],[nGroups,nBars]);
errorbar(x,barHeights,barErrors,'k','linestyle','none');
legend(barNames);
hold off
Figure: Before Saving (CORRECT)

Figure: After Saving and Reopening (INCORRECT)

댓글 수: 1
Andrew Soltisz
2021년 5월 18일
편집: Andrew Soltisz
2021년 5월 18일
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Errorbars에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
