xlim — Query or set x-axis limits.
xlim([xmin xmax]) sets the x-axis limits, while xlim() returns the current limits as a double vector.
Syntax
limits = xlim()
xlim([xmin xmax])
mode = xlim('mode')
method = xlim('method')
xlim('auto'|'manual')
xlim('tickaligned'|'tight'|'padded')All supported xlim forms
limits = xlim()
xlim([xmin xmax])
mode = xlim('mode')
method = xlim('method')
xlim('auto'|'manual')
xlim('tickaligned'|'tight'|'padded')
limits = xlim(axes)
xlim(axes,[xmin xmax])
xlim(axes,mode)Inputs
limits- Type
NumericArray- Required
- Yes
- Description
- Two-element numeric vector [xmin xmax].
mode- Type
StringScalar- Required
- Yes
- Description
- Axis-limit text token: 'auto'/'manual' set mode; 'tight'/'padded'/'tickaligned' select an automatic method; 'mode'/'method' query state.
axes- Type
AxesHandle- Required
- Yes
- Description
- Existing axes handle; does not change the current axes.
Returns
limits- Type
NumericArray- Description
- Displayed two-element vector [xmin xmax], including automatically selected bounds.
mode- Type
StringScalar- Description
- Current automatic or manual axis-limit mode.
method- Type
StringScalar- Description
- Current tick-aligned, tight, or padded automatic limit method.
Errors
RunMat:xlim:InvalidArgument- When
- Argument count, mode, or limit vector is invalid.
- Message
xlim: invalid argument
RunMat:xlim:Internal- When
- Internal plotting state update fails.
- Message
xlim: internal operation failed
RunMat:xlim:TooManyOutputs- When
- More than one output is requested.
- Message
xlim: at most one output is supported
Assigned setter outputs
The MATLAB-compatible setter form has no assigned output. RunMat mode preserves the existing one-output setter result as a gated extension; strict compatibility rejects that request before changing graphics state.
Behavior and compatibility
The two-element limits vector may use single, double, or any native integer class.
Native integer endpoints are ordered using their exact values before conversion to graphics coordinates.
Endpoints must be finite, increasing, and remain distinct in the graphics coordinate domain.
The accepted text tokens include 'auto', 'tight', and 'manual': 'auto' restores automatic selection, 'tight' selects the tight automatic-limit method, and 'manual' freezes the current numeric range. 'mode' queries the auto/manual state.
'tight', 'padded', and 'tickaligned' select distinct automatic limit methods; 'method' queries the selected method.
An existing axes handle can be supplied first for query or setter forms without selecting it as the current axes. Semiautomatic infinite endpoints and datetime/duration/categorical limits still require graphics-state support.
Placement
The control updates host graphics state. Resident control operands reject before provider access; existing resident plot data retains its rendering owner.
The whole-call allocation, graphics presentation, and callback execution routes still require integrated qualification.
Examples
Set integer limits
plot(1:10);
xlim(int16([0 12]))Query current limits
limits = xlim()Using xlim with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how xlim changes the result.
Run a small xlim example, explain the result, then change one input and compare the output.
Related Plotting functions
2D Charts
area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem
Other
addpoints · ancestor · animatedline · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · wordcloud · xlabel · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.