Inconsistent behavior updating tick labeling
古いコメントを表示
In the code below, I'm adding ticks to the Y axis. The first time I do it, YTickLabel updates correctly, adding an additional label. The second time I do it, YTickLabel fails to update properly, keeping the same number of elements when it should add one. I've played around with examples. In this case, the problem appears to be attributable to the fact that I'm adding a new tick below the first tick. If the second line of code is uncommented, then updating happens correctly. Is this a bug? Is there a workaround?
plot(0.5 :0.5:4.6)
%plot(0.0 :0.5:4.6)
YTick = get(gca,'YTick');
set(gca,'YTick',unique([ YTick , 1.9827 ]));
YTick = get(gca,'YTick');
YTickLabel = get(gca,'YTickLabel');
YTick
sprintf('YTick has %i elements', numel(YTick))
YTickLabel'
pause
set(gca,'YTick',unique([ YTick , 0.3519 ]));
YTick = get(gca,'YTick');
YTickLabel = get(gca,'YTickLabel');
YTick
sprintf('YTick has %i elements', numel(YTick))
YTickLabel'
pause
採用された回答
その他の回答 (0 件)
カテゴリ
ヘルプ センター および File Exchange で Axis Labels についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!