reference
labkit.app.plot.fitAxesToGraphics
Fit axes limits to finite plotted X/Y data.
Syntax
limits = labkit.app.plot.fitAxesToGraphics(ax)
limits = labkit.app.plot.fitAxesToGraphics(ax, graphicsHandles)
limits = labkit.app.plot.fitAxesToGraphics(..., Name=Value)Inputs
ax- Valid scalar MATLAB axes or uiaxes handle whose limits are changed.
graphicsHandles- Optional graphics handle array. Objects with numeric XData and YData contribute to the fitted range. When omitted, all current axes children are examined.
Name-Value Arguments
Padding- Nonnegative fractional padding added on each side of the data range. Default: 0.02. For logarithmic axes, padding is computed in base-10 logarithmic space.
EqualDataUnits- Logical value. true expands one fitted dimension so one data unit occupies the same screen distance on X and Y without changing the axes position. For logarithmic dimensions, equality is evaluated in base-10 logarithmic space. Default: false.
Outputs
limits- Scalar struct with x and y fields. Each field contains the applied two-element limit, or [] when that dimension had no usable data and was returned to automatic limit mode.
Description
fit ignores nonfinite XData and YData. Nonpositive values do not contribute to a logarithmic dimension. Supplying graphicsHandles lets an app exclude annotations such as reference lines from the fitted range.
Errors
labkit:app:plot:InvalidAxes- ax is not a valid scalar axes handle. labkit:app:plot:InvalidOptions or labkit:app:plot:InvalidOption - Name-value arguments are malformed or unsupported. Invalid supplied graphics handles are ignored when they do not expose numeric XData/YData.
Example
fig = figure("Visible", "off");
cleanup = onCleanup(@() close(fig));
ax = axes(fig);
h = plot(ax, [1 2 3], [10 20 15]);
xline(ax, 100);
limits = labkit.app.plot.fitAxesToGraphics(ax, h, "Padding", 0);
assert(isequal(limits.x, [1 3]))Related APIs
labkit.app.plot.clearAxes— Prepare an axes for an app-owned redraw.labkit.app.plot.clampPointToAxes— Keep data coordinates inside the visible axes box.labkit.app.plot.enablePopout— Add a standalone-figure action to an axes context menu.labkit.app.plot.fitCanvasToSource— Fit a preview axes into a fixed-aspect pixel frame.labkit.app.plot.offsetPointByAxesFraction— Move data coordinates by normalized axes fractions.labkit.app.plot.showMessage— Show a centered empty-state message in an axes.
Source
This page is generated from the MATLAB help text in +labkit/+app/+plot/fitAxesToGraphics.m.