Filter löschen
Filter löschen

get function returns unexpected values

3 Ansichten (letzte 30 Tage)
Igor Gayday
Igor Gayday am 20 Aug. 2020
Kommentiert: Igor Gayday am 20 Aug. 2020
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 Kommentare
Igor Gayday
Igor Gayday am 20 Aug. 2020
Bearbeitet: Igor Gayday am 20 Aug. 2020
Geoff, here is an example:
f = figure;
f.WindowState = 'maximized';
axis = gca;
axis.FontSize = 20;
hold on
plot(1:10, 1:10);
ylim([0, 100]);
y_ticks = get(gca, 'YTick');
As Bjorn correctly pointed out, the issue stems from the change of window's size. If you run this code, the values of y_ticks will be the same as if the window was not maximized. In the maximized version, displayed to me after the execution of this code, the ticks will be different.
Igor Gayday
Igor Gayday am 20 Aug. 2020
Bjorn, thank you, drawnow fixes this.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Graphics Performance finden Sie in Help Center und File Exchange

Produkte


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by