get function returns unexpected values
显示 更早的评论
I have a function, which creates a figure, plots something and changes several plot parameters. At some point I want to query current values of y-tick labels, which I do via:
current_ticks = get(gca, 'YTick');
The values that I get here are different from what I see on the plot once it's displayed. I believe this happens because get tries to query the plot in an intermediate state, before all adjustsments are processed, since putting
pause(0.1)
(or simply pausing in the debugger) right before the call to get changes its answer and makes it consistent with what I see in the figure. The same things happens if I use yticks function. Is there a better solution to this?
4 个评论
Geoff Hayes
2020-8-20
Igor - can you provide a minimal working example that demonstrates this behaviour?
Bjorn Gustavsson
2020-8-20
Well, the setting of tick-marks and such varies in a way (that I guess) is pleasing to the viewer. If you for example change the size of the figure you might get a larger number of tick-marks. This I've assumed is a deliberate design-choise of Mathworks. For your functionality it might be difficult to get a much better and robust solution. However it might look neater (and save you 0.1 s per run!) if you use drawnow instead of pause(0.1).
Igor Gayday
2020-8-20
编辑:Igor Gayday
2020-8-20
Igor Gayday
2020-8-20
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Distribution Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!