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!
