Need help understanding stretch-to-fit associated behavior

7 views (last 30 days)
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 Comment
Rik
Rik on 21 Feb 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.

Sign in to comment.

Accepted Answer

Evan
Evan on 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."

More Answers (0)

Categories

Find more on Formatting and Annotation in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!