Modify axis limits and tick values, add grid lines, combine multiple plots
You can customize axes by changing the limits, controlling the locations of the tick marks, formatting the tick labels, or adding grid lines. You also can combine multiple plots, either using separate axes in the same figure, or by combining the plots in the same axes, with the option to add a second y-axis.
Functions
expand all
Axes Limits, Scale, and Aspect Ratio
Limits
xlim | Set or query x-axis limits |
ylim | Set or query y-axis limits |
zlim | Set or query z-axis limits |
Scale
xscale | Set or query x-axis scale (linear or logarithmic) (Since R2023b) |
yscale | Set or query y-axis scale (linear or logarithmic) (Since R2023b) |
zscale | Set or query z-axis scale (linear or logarithmic) (Since R2023b) |
Plot Box and Aspect Ratio
box | Display axes outline |
tightPosition | Position of axes plotting area (Since R2022b) |
axis | Set axis limits and aspect ratios |
daspect | Control data unit length along each axis |
pbaspect | Control relative lengths of each axis |
Ticks, Grid Lines, and Labels
Tick Values
xticks | Set or query x-axis tick values |
yticks | Set or query y-axis tick values |
zticks | Set or query z-axis tick values |
xtickformat | Specify x-axis tick label format |
ytickformat | Specify y-axis tick label format |
ztickformat | Specify z-axis tick label format |
ruler2num | Convert data from specific ruler to numeric data |
num2ruler | Convert numeric data for use with specific ruler |
Grid Lines and Tick Marks
grid | Display or hide axes grid lines |
xtickangle | Rotate x-axis tick labels |
ytickangle | Rotate y-axis tick labels |
ztickangle | Rotate z-axis tick labels |
Labels
xticklabels | Set or query x-axis tick labels |
yticklabels | Set or query y-axis tick labels |
zticklabels | Set or query z-axis tick labels |
xsecondarylabel | Set x-axis secondary label (Since R2023b) |
ysecondarylabel | Set y-axis secondary label (Since R2023b) |
zsecondarylabel | Set z-axis secondary label (Since R2023b) |
Multiple Plots and Data Series
Combining Plots
hold | Retain current plot when adding new plots |
yyaxis | Create chart with two y-axes |
legend | Add legend to axes |
Customizing Multiple Data Series
colororder | Set or query color order palette (Since R2019b) |
orderedcolors | Color palettes for visualizing multiple data series (Since R2023b) |
linestyleorder | Set or query line style order (Since R2024a) |
Tiling Plots
tiledlayout | Create tiled chart layout for displaying subplots (Since R2019b) |
nexttile | Create axes in tiled chart layout (Since R2019b) |
tilenum | Tile location numbers in tiled chart layout (Since R2022b) |
tilerowcol | Row and column numbers in tiled chart layout (Since R2022b) |
subplot | Create axes in tiled positions |
Clear or Create Axes
cla | Clear axes |
clf | Clear figure |
axes | Create Cartesian axes |
figure | Create figure window |
Properties
Axes Properties | Axes appearance and behavior |
Legend Properties | Legend appearance and behavior |
TiledChartLayout Properties | Tiled chart layout appearance and behavior (Since R2019b) |
Topics
Limits, Ticks, and Grids
- Specify Axis Limits
Control where data appears in the axes by setting the axis limits. - Specify Axis Tick Values and Labels
Customize the tick values and labels along an axis, such as editing the tick value placement or modifying the tick label text and formatting. - Add Grid Lines and Edit Placement
Add grid lines to a graph and modify their placement and appearance. - Using Graphics Smoothing
This example shows how to use graphics and font smoothing in your plots.
Multiple Plots
- Combine Multiple Plots
Show multiple plots together in the same figure, either by combining the plots in the same axes or by creating a tiled chart layout. (Since R2019b) - Create Chart with Two y-Axes
Create a chart with y-axes on both the left and right sides. - Modify Properties of Charts with Two y-Axes
Modify charts with two y-axes by setting axes properties or by accessing the underlying ruler objects. - Display Data with Multiple Scales and Axes Limits
Learn about techniques for visualizing data with multiple x- and y-axes, multiple colorbars, or with an x-axis that is broken into intervals. - Customized Presentations and Special Effects with Tiled Chart Layouts
Explore the different ways you can use a tiled chart layout to arrange the elements in a visualization.
Size and Aspect Ratio
- Control Ratio of Axis Lengths and Data Unit Lengths
Control the axis and data unit lengths by setting the plot box aspect ratio and the data aspect ratio. - Control Axes Layout
Control the axes size and position, the layout of titles and labels, and the axes resize behavior. - Clipping in Plots and Graphs
This example shows how MATLAB® uses clipping in plots and how to control clipping.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- Deutsch
- English
- Français
- United Kingdom (English)
Contact your local office