Need help understanding stretch-to-fit associated behavior

7 vues (au cours des 30 derniers jours)
Evan
Evan le 21 Fév 2017
Réponse apportée : Evan le 18 Mar 2017
Matlab documentation states that when stretch-to-fill is enabled (as it is by default), then "the axes might not exactly match the data aspect ratio, plot box aspect ratio, and camera-view angle values stored in its DataAspectRatio, PlotBoxAspectRatio, and CameraViewAngle properties." Setting the 'mode' of any one of these three properties to 'manual' should turn off stretch-to-fill. It makes sense then, that if I make a plot and then set DataAspectRatioMode to manual:
figure;plot(0.1:0.1:pi,sin(0.1:0.1:pi))
daspect manual
Then the physical appearance of the plot should change, as stretch-to-fit has been turned off and the DataAspectRatio property is now accurate. It also makes sense that if I make the same plot and set PlotBoxAspectRatioMode to manual, then the values of DataAspectRatio should change (they do), as Matlab needs to make consistent the fact that (1) I've frozen the axis lims and (2) stretch-to-fit is turned off:
figure;plot(0.1:0.1:pi,sin(0.1:0.1:pi))
daspect
pbaspect manual
daspect
However, I do not understand why if I then set DataAspectRatioMode to manual, the plot changes again:
figure;plot(0.1:0.1:pi,sin(0.1:0.1:pi))
daspect
pbaspect manual
daspect
daspect manual
daspect
In fact, if you look at the plot, the behavior is as if setting the DataAspectRatioMode to manual in this context sets the axis limits to 'tight.' Does anyone know why this happens?
  1 commentaire
Rik
Rik le 21 Fév 2017
I'll be interested in the answer as well. Sometimes it is difficult to see the logic behind certain behavior of Matlab, and in my experience axes and figures are the most difficult to understand.

Connectez-vous pour commenter.

Réponse acceptée

Evan
Evan le 18 Mar 2017
Answer is here. When LimitModes are auto while DataAspectRatioMode and PlotBoxAspectRatioMode are manual, "MATLAB chooses limits that completely fit and center the plot within the specified PlotBoxAspectRatio given the specified DataAspectRatio."

Plus de réponses (0)

Catégories

En savoir plus sur Formatting and Annotation dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by