I can't read UIAxis Exponent value

1 vue (au cours des 30 derniers jours)
Ron Fredericks
Ron Fredericks le 13 Fév 2022
Réponse apportée : Dave B le 13 Fév 2022
I spent some time trying to figure out how to read the Axis Exponent value for a project developed with App Deisigner (a great tool btw): https://www.mathworks.com/help/releases/R2021b/matlab/ref/matlab.graphics.axis.decorator.numericruler-properties.html?s_tid=doc_srchtitle#bun6izd-1-Exponent
To be clear, writing a value to Exponent field is not a problem. But reading always returns a 0. UNLESS the Exponent field is written to first.
I suggest allowing Exponent value to be read, or stating in the docs that this is a "write-only" entity. And then after writing, the Exponent value can be read.
My code in the figures also shows my not-so-eligant work-around to read the Exponent value.
See the 4 figures below showing debug values before and after writting to Exponent....
Example:
Figure 1: Exponent initially set to -4
Figure 2: Initial attempt to read Exponent fails (x_exp_bf value should have been -4)
Figure 3: Final Value After Writting -6 to Exponent
Figure 4: Exponent Successfully Saved to x_exp_af After Writting a Value to Exponent First
Conclusion: seems like a bug to have to write to Exponent before reading Exponent.

Réponse acceptée

Dave B
Dave B le 13 Fév 2022
This actually isn't quite the bug you've identified, although I'm surprised by the behavior:
The (automatically calculated, not manually set) exponent is determined by some automatic behavior, but MATLAB hasn't selected performed this behavior at the moment you're querying it. As a general rule, properties that - in the automatic mode - depend on things like limit picking should force the an update of the value when you query them, but this does not appear to be the case with exponent. If you report this to tech support I can try to improve this for future releases.
In the mean time, if you'd like to read the automatically calculated expoenent, a workaround is to call drawnow just before querying it:
ax = axes; % this should be the same for uiaxes, but I can't use it in the web version that ML Answers relies on
ax.XLim = [0 1e9];
sprintf("Incorrect Exponent %d",ax.XAxis.Exponent)
ans = "Incorrect Exponent 0"
drawnow
sprintf("Correct Exponent %d",ax.XAxis.Exponent)
ans = "Correct Exponent 8"

Plus de réponses (0)

Catégories

En savoir plus sur Graphics Performance dans Help Center et File Exchange

Produits


Version

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by