Matlab axis size

Matlab axis size DEFAULT

Specify Axis Limits

You can control where data appears in the axes by setting the x-axis, y-axis, and z-axis limits. You also can change where the x-axis and y-axis lines appear (2-D plots only) or reverse the direction of increasing values along each axis.

Change Axis Limits

Create a line plot. Specify the axis limits using the and functions. For 3-D plots, use the function. Pass the functions a two-element vector of the form .

x = linspace(-10,10,200); y = sin(4*x)./exp(x); plot(x,y) xlim([0 10]) ylim([-0.4 0.8])

Use Semiautomatic Axis Limits

Set the maximum x-axis limit to 0 and the minimum y-axis limit to -1. Let MATLAB choose the other limits. For an automatically calculated minimum or maximum limit, use or , respectively.

[X,Y,Z] = peaks; surf(X,Y,Z) xlabel('x-axis') ylabel('y-axis') xlim([-inf 0]) ylim([-1 inf])

Revert Back to Default Limits

Create a mesh plot and change the axis limits. Then revert back to the default limits.

[X,Y,Z] = peaks; mesh(X,Y,Z) xlim([-2 2]) ylim([-2 2]) zlim([-5 5])
xlim auto ylim auto zlim auto

Reverse Axis Direction

Control the direction of increasing values along the x-axis and y-axis by setting the and properties of the object. Set these properties to either or (the default). Use the command to access the object.

stem(1:10) ax = gca; ax.XDir = 'reverse'; ax.YDir = 'reverse';

Display Axis Lines through Origin

By default, the x-axis and y-axis appear along the outer bounds of the axes. Change the location of the axis lines so that they cross at the origin point by setting the and properties of the object. Set to either , , or . Set to either , , or . These properties only apply to axes in a 2-D view.

x = linspace(-5,5); y = sin(x); plot(x,y) ax = gca; ax.XAxisLocation = 'origin'; ax.YAxisLocation = 'origin';

Remove the axes box outline.

See Also

Functions

Properties

Related Topics

You have a modified version of this example. Do you want to open this example with your edits?

Sours: https://www.mathworks.com/help/matlab/creating_plots/change-axis-limits-of-graph.html

Axes Properties

Main Content

properties control the appearance and behavior of an object. By changing property values, you can modify certain aspects of the axes. Use dot notation to query and set properties.

ax = gca; c = ax.Color; ax.Color = 'blue';

Font

expand all

— Font name
supported font name |

Font name, specified as a supported font name or . To display and print text properly, you must choose a font that your system supports. The default font depends on your operating system and locale.

To use a fixed-width font that looks good in any locale, use . The fixed-width font relies on the root property. Setting the root property causes an immediate update of the display to use the new font.

— Character thickness
(default) |

Character thickness, specified as or .

MATLAB® uses the property to select a font from those available on your system. Not all fonts have a bold weight. Therefore, specifying a bold font weight can still result in the normal font weight.

— Font size
scalar numeric value

Font size, specified as a scalar numeric value. The font size affects the title, axis labels, and tick labels. It also affects any legends or colorbars associated with the axes. The default font size depends on the specific operating system and locale. By default, the font size is measured in points. To change the units, set the property.

MATLAB automatically scales some of the text to a percentage of the axes font size.

  • Titles and axis labels — 110% of the axes font size by default. To control the scaling, use the and properties.

  • Legends and colorbars — 90% of the axes font size by default. To specify a different font size, set the property for the or object instead.

Example:

— Selection mode for font size
(default) |

Selection mode for the font size, specified as one of these values:

  • — Font size specified by MATLAB. If you resize the axes to be smaller than the default size, the font size might scale down to improve readability and layout.

  • — Font size specified manually. Do not scale the font size as the axes size changes. To specify the font size, set the property.

— Character slant
(default) |

Character slant, specified as or .

Not all fonts have both font styles. Therefore, the italic font might look the same as the normal font.

— Scale factor for label font size
(default) | numeric value greater than 0

Scale factor for the label font size, specified as a numeric value greater than 0. The scale factor is applied to the value of the property to determine the font size for the x-axis, y-axis, and z-axis labels.

Example:

— Scale factor for title font size
(default) | numeric value greater than 0

Scale factor for the title font size, specified as a numeric value greater than 0. The scale factor is applied to the value of the property to determine the font size for the title.

Example:

— Title character thickness
(default) |

Title character thickness, specified as one of these values:

  • — Default weight as defined by the particular font

  • — Thicker characters than normal

— Subtitle character thickness
(default) |

Subtitle character thickness, specified as one of these values:

  • — Default weight as defined by the particular font

  • — Thicker characters than normal

— Font size units
(default) | | | |

Font size units, specified as one of these values.

Description
Points. One point equals 1/72 inch.
Inches.
Centimeters.
Interpret font size as a fraction of the axes height. If you resize the axes, the font size modifies accordingly. For example, if the is in normalized units, then the text is 1/10 of the height value stored in the axes property.

Pixels.

Starting in R2015b, distances in pixels are independent of your system resolution on Windows® and Macintosh systems.

  • On Windows systems, a pixel is 1/96th of an inch.

  • On Macintosh systems, a pixel is 1/72nd of an inch.

  • On Linux® systems, the size of a pixel is determined by your system resolution.

To set both the font size and the font units in a single function call, you first must set the property so that the object correctly interprets the specified font size.

— Font smoothing
(default) | on/off logical value

Font smoothing, specified as or , or as numeric or logical () or (). A value of is equivalent to true, and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

ValueDescriptionResult

Use antialiasing to make text appear smoother on the screen.

Example:

Do not use antialiasing. Use this setting if the text seems blurry.

Example:

Ticks

expand all

, , — Tick values
(default) | vector of increasing values

Tick values, specified as a vector of increasing values. If you do not want tick marks along the axis, then specify an empty vector . The tick values are the locations along the axis where the tick marks appear. The tick labels are the labels that you see next to each tick mark. Use the , , and properties to specify the associated labels.

Example:

Example:

Alternatively, use the , , and functions to specify the tick values. For an example, see Specify Axis Tick Values and Labels.

Data Types: | | | | | | | | | | | |

, , — Selection mode for tick values
(default) |

Selection mode for the tick values, specified as one of these values:

  • — Automatically select the tick values based on the range of data for the axis.

  • — Manually specify the tick values. To specify the values, set the , , or property.

Example:

, , — Tick labels
(default) | cell array of character vectors | string array | categorical array

Tick labels, specified as a cell array of character vectors, string array, or categorical array. If you do not want tick labels to show, then specify an empty cell array . If you do not specify enough labels for all the ticks values, then the labels repeat.

Tick labels support TeX and LaTeX markup. See the property for more information.

If you specify this property as a categorical array, MATLAB uses the values in the array, not the categories.

As an alternative to setting this property, you can use the , , and functions. For an example, see Specify Axis Tick Values and Labels.

Example:

, , — Selection mode for tick labels
(default) |

Selection mode for the tick labels, specified as one of these values:

  • — Automatically select the tick labels.

  • — Manually specify the tick labels. To specify the labels, set the , , or property.

Example:

— Tick label interpreter
(default) | |

Tick label interpreter, specified as one of these values:

  • — Interpret labels using a subset of the TeX markup.

  • — Interpret labels using a subset of LaTeX markup. When you specify the tick labels, use dollar signs around each element in the cell array.

  • — Display literal characters.

TeX Markup

By default, MATLAB supports a subset of TeX markup. Use TeX markup to add superscripts and subscripts, modify the text type and color, and include special characters in the labels.

Modifiers remain in effect until the end of the text. Superscripts and subscripts are an exception because they modify only the next character or the characters within the curly braces. When you set the interpreter to , the supported modifiers are as follows.

ModifierDescriptionExample
Superscript
Subscript
Bold font
Italic font
Oblique font (usually the same as italic font)
Normal font
Font name — Replace with the name of a font family. You can use this in combination with other modifiers.
Font size —Replace with a numeric scalar value in point units.
Font color — Replace with one of these colors: , , , , , , , , , , or .
Custom font color — Replace with a three-element RGB triplet.

This table lists the supported special characters for the interpreter.

Character SequenceSymbolCharacter SequenceSymbolCharacter SequenceSymbol

α

υ

~

χ

β

ψ

γ

ω

δ

Γ

ϵ

Δ

ζ

Θ

η

Λ

θ

Ξ

ϑ

Π

ι

Σ

κ

ϒ

λ

Φ

µ

Ψ

º

ν

Ω

±

ξ

π

ρ

σ

ς

÷

τ

·

ο

¬

x

...

´

ϖ

|

©

LaTeX Markup

To use LaTeX markup, set the property to . Use dollar symbols around the labels, for example, use for inline mode or for display mode.

The displayed text uses the default LaTeX font style. The , , and properties do not have an effect. To change the font style, use LaTeX markup within the text. The maximum size of the text that you can use with the LaTeX interpreter is 1200 characters. For multiline text, the maximum size of the text reduces by about 10 characters per line.

For examples that use TeX and LaTeX, see Greek Letters and Special Characters in Chart Text. For more information about the LaTeX system, see The LaTeX Project website at https://www.latex-project.org/.

, , — Tick label rotation
(default) | numeric value in degrees

Tick label rotation, specified as a numeric value in degrees. Positive values give counterclockwise rotation. Negative values give clockwise rotation.

Example:

Example:

Alternatively, use the , , and functions.

, , — Minor tick marks
on/off logical value

Minor tick marks, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display minor tick marks between the major tick marks on the axis. The space between the major tick marks determines the number of minor tick marks. This value is the default for an axis with a log scale.

  • — Do not display minor tick marks. This value is the default for an axis with a linear scale.

Example:

— Tick mark direction
(default) | | |

Tick mark direction, specified as one of these values:

  • — Direct the tick marks inward from the axis lines. (Default for 2-D views)

  • — Direct the tick marks outward from the axis lines. (Default for 3-D views)

  • — Center the tick marks over the axis lines.

  • — Do not display any tick marks.

— Selection mode for
(default) |

Selection mode for the property, specified as one of these values:

  • — Automatically select the tick direction based on the current view.

  • — Manually specify the tick direction. To specify the tick direction, set the property.

Example:

— Tick mark length
(default) | two-element vector

Tick mark length, specified as a two-element vector of the form . The first element is the tick mark length in 2-D views and the second element is the tick mark length in 3-D views. Specify the values in units normalized relative to the longest of the visible x-axis, y-axis, or z-axis lines.

Example:

Rulers

expand all

, , — Minimum and maximum axis limits
(default) | two-element vector of the form

Minimum and maximum limits, specified as a two-element vector of the form , where is greater than . You can specify the limits as numeric, categorical, datetime, or duration values. However, the type of values that you specify must match the type of values along the axis.

You can specify both limits, or specify one limit and let MATLAB automatically calculate the other. For an automatically calculated minimum or maximum limit, use or , respectively. MATLAB uses the limit method to calculate the corresponding limit.

Example:

Example:

Example:

Alternatively, use the , , and functions to set the limits. For an example, see Specify Axis Limits.

Data Types: | | | | | | | | | | |

, , — Selection mode for axis limits
(default) |

Selection mode for the axis limits, specified as one of these values:

  • — Enable automatic limit selection, which is based on the total span of the plotted data and the value of the , , or property.

  • — Manually specify the axis limits. To specify the axis limits, set the , , or property.

Example:

, , — Axis limit selection method
(default) | |

Axis limit selection method, specified as a value from the table. The examples in the table show the approximate appearance for different values of the property. Your results might differ depending on your data, the size of the axes, and the type of plot you create.

ValueDescriptionExample ()

In general, align the edges of the axes box with the tick marks that are closest to your data without excluding any data. The appearance might vary depending on the type of data you plot and the type of chart you create.

Fit the axes box tightly around the data by setting the axis limits equal to the range of the data.

Fit the axes box around the data with a thin margin of padding on each side. The width of the margin is approximately 7% of your data range.

Note

The axis limit method has no effect when the corresponding mode property (, , or ) is set to .

, , — Axis ruler
ruler object

Axis ruler, returned as a ruler object. The ruler controls the appearance and behavior of the x-axis, y-axis, or z-axis. Modify the appearance and behavior of a particular axis by accessing the associated ruler and setting ruler properties. The type of ruler that MATLAB creates for each axis depends on the plotted data. For a list of ruler properties that objects support, see:

For example, access the ruler for the x-axis through the property. Then, change the property of the ruler, and thus the color of the x-axis, to red. Similarly, change the color of the y-axis to green.

ax = gca; ax.XAxis.Color = 'r'; ax.YAxis.Color = 'g';
If the object has two y-axes, then the property stores two ruler objects.

x-axis location
(default) | |

x-axis location, specified as one of the values in this table. This property applies only to 2-D views.

ValueDescriptionResult

Bottom of the axes.

Example:

Empty axes with the x-axis at the bottom.

Top of the axes.

Example:

Empty axes with the x-axis at the top.

Through the origin point (0,0).

Example:

Empty axes with the x-axis at the origin.

y-axis location
(default) | |

y-axis location, specified as one of the values in this table. This property applies only to 2-D views.

ValueDescriptionResult

Left side of the axes.

Example:

Empty axes with the y-axis on the left.

Right side of the axes.

Example:

Empty axes with the y-axis on the right.

Through the origin point (0,0).

Example:

Empty axes with the y-axis at the origin.

, , — Color of axis line, tick values, and labels
(default) | RGB triplet | hexadecimal color code | | | | ...

Color of the axis line, tick values, and labels in the x, y, or z direction, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. The color you specify also affects the grid lines, unless you specify the grid line color using the or property.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range ; for example, .

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol () followed by three or six hexadecimal digits, which can range from to . The values are not case sensitive. Thus, the color codes , , , and are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance

Example:

Example:

Example:

Example:

— Property for setting x-axis grid color
(default) |

Property for setting the x-axis grid color, specified as or . The mode value only affects the x-axis grid color. The x-axis line, tick values, and labels always use the value, regardless of the mode.

The x-axis grid color depends on both the property and the property, as shown here.

XColorModeGridColorModex-Axis Grid Color
property
property
property
property

The x-axis minor grid color depends on both the property and the property, as shown here.

XColorModeMinorGridColorModex-Axis Minor Grid Color
property
property
property
property

— Property for setting y-axis grid color
(default) |

Property for setting the y-axis grid color, specified as or . The mode value only affects the y-axis grid color. The y-axis line, tick values, and labels always use the value, regardless of the mode.

The y-axis grid color depends on both the property and the property, as shown here.

YColorModeGridColorModey-Axis Grid Color
property
property
property
property

The y-axis minor grid color depends on both the property and the property, as shown here.

YColorModeMinorGridColorModey-Axis Minor Grid Color
property
property
property
property

— Property for setting z-axis grid color
(default) |

Property for setting the z-axis grid color, specified as or . The mode value only affects the z-axis grid color. The z-axis line, tick values, and labels always use the value, regardless of the mode.

The z-axis grid color depends on both the property and the property, as shown here.

ZColorModeGridColorModez-Axis Grid Color
property
property
property
property

The z-axis minor grid color depends on both the property and the property, as shown here.

ZColorModeMinorGridColorModez-Axis Minor Grid Color
property
property
property
property

x-axis direction
(default) |

x-axis direction, specified as one of these values.

ValueDescriptionResult in 2-DResult in 3-D

Values increase from left to right.

Example:

2-D axes with the x-axis direction set to 'normal'. The tick values for the x-axis increase from left to right.

3-D axes with the x-axis direction set to 'normal'. If you look at the x-y plane, the x-axis tick values increase from left to right.

Values increase from right to left.

Example:

2-D axes with the x-axis direction set to 'reverse'. The tick values for the x-axis increase from right to left.

3-D axes with the x-axis direction set to 'reverse'. If you look at the x-y plane, the x-axis tick values increase from right to left.

y-axis direction
(default) |

y-axis direction, specified as one of these values.

ValueDescriptionResult in 2-DResult in 3-D

Values increase from bottom to top (2-D view) or front to back (3-D view).

Example:

2-D axes with the y-axis direction set to 'normal'. The tick values for the y-axis increase from bottom to top.

3-D axes with the y-axis direction set to 'normal'. If you look at the x-y plane, the y-axis tick values increase from bottom to top.

Values increase from top to bottom (2-D view) or back to front (3-D view).

Example:

2-D axes with the y-axis direction set to 'reverse'. The tick values for the y-axis increase from top to bottom.

3-D axes with the y-axis direction set to 'reverse'. If you look at the x-y plane, the y-axis tick values increase from top to bottom.

z-axis direction
(default) |

z-axis direction, specified as one of these values.

ValueDescriptionResult in 3-D

Values increase pointing out of the screen (2-D view) or from bottom to top (3-D view).

Example:

3-D axes with the z-axis direction set to 'normal'. If the z-axis is the vertical axis, its tick values increase from bottom to top.

Values increase pointing into the screen (2-D view) or from top to bottom (3-D view).

Example:

3-D axes with the z-axis direction set to 'reverse'. If the z-axis is the vertical axis, its tick values increase from top to bottom.

, , — Scale of values along axis
(default) |

Axis scale, specified as one of these values.

ValueDescriptionResult

Linear scale

Example:

Axis with the scale set to 'linear'. The tick values that start at 0 and increment by adding 100 to the previous value.

Log scale

Example:

Note

The axes might exclude coordinates in some cases:

  • If the coordinates include positive and negative values, only the positive values are displayed.

  • If the coordinates are all negative, all of the values are displayed on a log scale with the appropriate sign.

  • Zero values are not displayed.

Axis with the scale set to 'log'. The tick values start at 0.10 (10 raised to -1). Each major tick value increases by a factor of 10.

Grids

expand all

, , — Grid lines
(default) | on/off logical value

Grid lines, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display grid lines perpendicular to the axis; for example, along lines of constant x, y, or z values.

  • — Do not display the grid lines.

Alternatively, use the or command to set all three properties to or , respectively. For more information, see .

Example:

— Placement of grid lines and tick marks
(default) |

Placement of grid lines and tick marks in relation to graphic objects, specified as one of these values:

  • — Display tick marks and grid lines under graphics objects.

  • — Display tick marks and grid lines over graphics objects.

This property affects only 2-D views.

Example:

— Line style for grid lines
(default) | | | |

Line style for grid lines, specified as one of the line styles in this table.

Line StyleDescriptionResulting Line
Solid line
Dashed line
Dotted line
Dash-dotted line
No lineNo line

To display the grid lines, use the command or set the , , or property to .

Example:

— Color of grid lines
(default) | RGB triplet | hexadecimal color code | | | | ...

Color of grid lines, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name.

For a custom color, specify an RGB triplet or a hexadecimal color code.

  • An RGB triplet is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range ; for example, .

  • A hexadecimal color code is a character vector or a string scalar that starts with a hash symbol () followed by three or six hexadecimal digits, which can range from to . The values are not case sensitive. Thus, the color codes , , , and are equivalent.

Alternatively, you can specify some common colors by name. This table lists the named color options, the equivalent RGB triplets, and hexadecimal color codes.

Color NameShort NameRGB TripletHexadecimal Color CodeAppearance
Not applicableNot applicableNot applicableNo color

Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.

RGB TripletHexadecimal Color CodeAppearance

To set the colors for the axes box outline, use the , , and properties.

To display the grid lines, use the command or set the , , or property to .

Example:

Example:

Example:

Example:

— Property for setting grid color
(default) |

Property for setting the grid color, specified as one of these values:

  • — Check the values of the , , and properties to determine the grid line colors for the x, y, and z directions.

  • — Use to set the grid line color for all directions.

— Grid-line transparency
(default) | value in the range

Grid-line transparency, specified as a value in the range . A value of means opaque and a value of means completely transparent.

Example:

— Selection mode for
(default) |

Selection mode for the property, specified as one of these values:

  • — Default transparency value of .

  • — Manually specify the transparency value. To specify the value, set the property.

Example:

, , — Minor grid lines
(default) | on/off logical value

Minor grid lines, specified as or , or as numeric or logical () or (). A value of is equivalent to , and is equivalent to . Thus, you can use the value of this property as a logical value. The value is stored as an on/off logical value of type .

  • — Display grid lines aligned with the minor tick marks of the axis. You do not need to enable minor ticks to display minor grid lines.

  • — Do not display grid lines.

Alternatively, use the command to toggle the visibility of the minor grid lines.

Example:

— Line style for minor grid lines
(default) | | | |

Line style for minor grid lines, specified as one of the line styles shown in this table.

Line StyleDescriptionResulting Line
Solid line
Sours: https://www.mathworks.com/help/matlab/ref/matlab.graphics.axis.axes-properties.html
  1. Big sonia netflix
  2. Wowhead mythic
  3. Case ih 5220

Axes Appearance

Main Content

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 and Aspect Ratios

Set or query x-axis limits
Set or query y-axis limits
Set or query z-axis limits
Set axis limits and aspect ratios
Display axes outline
Control data unit length along each axis
Control relative lengths of each axis

Grid Lines, Tick Values, and Labels

Multiple Plots

Combining Plots

Retain current plot when adding new plots
Create chart with two y-axes
Add legend to axes
Set color order for visualizing multiple data series

Tiling Plots

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.

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: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office

Sours: https://www.mathworks.com/help/matlab/axes.html

axis

Main Content

Description

example

specifies the limits for the current axes. Specify the limits as vector of four, six, or eight elements.

example

uses a predefined style to set the limits and scaling. For example, specify the style as to use equal data unit lengths along each axis.

example

sets whether MATLAB® automatically chooses the limits or not. Specify the mode as , , or one of the semiautomatic options, such as .

example

, where is , places the origin at the upper left corner of the axes. The y values increase from top to bottom. The default for is , which places the origin at the lower left corner. The y values increase from bottom to top.

example

, where is , turns off the display of the axes background. Plots in the axes still display. The default for is , which displays the axes background.

example

returns the x-axis and y-axis limits for the current axes. For 3-D axes, it also returns the z-axis limits. For polar axes, it returns the theta-axis and r-axis limits.

returns the current settings for the axis limit selection, the axes visibility, and the y-axis direction. This syntax will be removed in a future release. Use the , , , , and properties of the axes to get the values instead.

example

uses the axes or polar axes specified by instead of the current axes. Specify as the first input argument for any of the previous syntaxes. Use single quotes around input arguments that are character vectors, such as .

Examples

collapse all

Set Axis Limits

Plot the sine function.

x = linspace(0,2*pi); y = sin(x); plot(x,y,'-o')

Change the axis limits so that the x-axis ranges from to and the y-axis ranges from -1.5 to 1.5.

Add Padding Around Stairstep Plot

Create a stairstep plot, and use the command to add a margin of padding between the plot and the plot box.

x = 0:12; y = sin(x); stairs(x,y) axis padded

Use Semiautomatic Axis Limits

Create a plot. Set the limits for the x-axis and set the minimum y-axis limit. Use an automatically calculated value for the maximum y-axis limit.

x = linspace(-10,10,200); y = sin(4*x)./exp(.1*x); plot(x,y) axis([-10 10 0 inf])

Set Axis Limits for Multiple Axes

Starting in R2019b, you can display a tiling of plots using the and functions. Call the function to create a 2-by-1 tiled chart layout. Call the function to create the axes objects and . Plot data in each axes. Then set the axis limits for both axes to the same values.

tiledlayout(2,1) x1 = linspace(0,10,100); y1 = sin(x1); ax1 = nexttile; plot(ax1,x1,y1) x2 = linspace(0,5,100); y2 = sin(x2); ax2 = nexttile; plot(ax2,x2,y2) axis([ax1 ax2],[0 10 -1 1])

Display Plot Without Axes Background

Plot a surface without displaying the axes lines and background.

Use Tight Axis Limits and Return Values

Plot a surface. Set the axis limits to equal the range of the data so that the plot extends to the edges of the axes.

Return the values of the current axis limits.

l = 1×6 1.0000 49.0000 1.0000 49.0000 -6.5466 8.0752

Change Direction of Coordinate System

Create a checkerboard plot and change the direction of the coordinate system.

First, create the plot using the colormap. By default, the x values increase from left to right and the y values increase from bottom to top.

C = eye(10); pcolor(C) colormap summer

Reverse the coordinate system so that the y values increase from top to bottom.

Retain Current Axis Limits When Adding New Plots

Plot a sine wave.

x = linspace(0,10); y = sin(x); plot(x,y)

Add another sine wave to the axes using . Keep the current axis limits by setting the limits mode to manual.

y2 = 2*sin(x); hold on axis manual plot(x,y2) hold off

If you want the axes to choose the appropriate limits, set the limits mode back to automatic.

Input Arguments

collapse all

— Axis limits
four-element vector | six-element vector | eight-element vector

Axis limits, specified as a vector of four, six, or eight elements.

For Cartesian axes, specify the limits in one of these forms:

  • — Set the x-axis limits to range from to . Set the y-axis limits to range from to .

  • — Also set the z-axis limits to range from to .

  • — Also set the color limits. is the data value that corresponds to the first color in the colormap. is the data value that corresponds to the last color in the colormap.

The , , , and properties for the object store the limit values.

For polar axes, specify the limits in this form:

  • — Set the theta-axis limits to range from to . Set the r-axis limits to range from to .

The and properties for the object store the limit values.

For partially automatic limits, use or for the limits you want the axes to choose automatically. For example, lets the axes choose the appropriate minimum x-axis limit and maximum y-axis limit. It uses the specified values for the maximum x-axis limit and minimum y-axis limit.

Note

If the x-axis, y-axis, or z-axis displays categorical, datetime, or duration values, then use the , , and functions to set the limits instead.

Example:

Example:

Example:

— Manual, automatic, or semiautomatic selection of axis limits
| | | | | | |

Manual, automatic, or semiautomatic selection of axis limits, specified as one of the values in this table. All of the auto mode values use the to calculate the limits for the particular axis or set of axes you specify.

ValueDescriptionAxes Properties That Change
Freeze all axis limits at their current values. Sets , , and to . If you are working with polar axes, then this option sets and to .
Automatically choose all axis limits. Sets , , and to . If you are working with polar axes, then this option sets and to .
Automatically choose the x-axis limits. Sets to .
Automatically choose the y-axis limits. Sets to .
Automatically choose the z-axis limits. Sets to .
Automatically choose the x-axis and y-axis limits. Sets and to .
Automatically choose the x-axis and z-axis limits. Sets and to .
Automatically choose the y-axis and z-axis limits. Sets and to .

Note

You cannot use these options with polar axes.

— Axis limits and scaling
| | | | | | |

Axis limits and scaling, specified as one of these values.

ValueDescriptionAxes Properties That Change
In general, align the edges of the axes box with the tick marks that are closest to your data without excluding any data. The appearance might vary depending on the type of data you plot and the type of chart you create.

, , and change to .

, , and change to .

, , and automatically update to incorporate new data added to the axes. To keep the limits from changing when using , use .

Fit the axes box tightly around the data by setting the axis limits equal to the range of the data.

, , and change to . If you are working with polar axes, then and change.

, , and change to .

, , and automatically update to incorporate new data added to the axes. To keep the limits from changing when using , use .

Fit the axes box around the data with a thin margin of padding on all sides. The width of the margin is approximately 7% of your data range.

, , and change to .

, , and change to .

, , and automatically update to incorporate new data added to the axes. To keep the limits from changing when using , use .

Use the same length for the data units along each axis.

Sets to and sets and to . For 2-D views, it also sets the and appropriately so that the axes fills its allotted space within the parent figure or other container. For 3-D Views, , , and are set to and , , and are set to .

This style disables the default “stretch-to-fill” behavior.

Use the same length for the data units along each axis and fit the axes box tightly around the data.

Sets to , to , and to . It also sets , , and to and , , and to .

This style disables the default “stretch-to-fill” behavior.

Use axis lines with equal lengths. Adjust the increments between data units accordingly.

Sets to and sets the associated mode property to manual.

This style disables the default “stretch-to-fill” behavior.

Enable the “stretch-to-fill” behavior (the default). The lengths of each axis line fill the position rectangle defined in the property of the axes.

Sets and to .

Freeze the aspect ratio properties.

Sets and to .

Restore the default behavior.

Sets and to .

For more information on the plot box aspect ratio and the data aspect ratio, see the and properties.

Note

You cannot use these options with polar axes, except for the and commands.

— y-axis direction
(default) |

y-axis direction, specified as one of these values:

  • — Default direction. For axes in a 2-D view, the y-axis is vertical with values increasing from bottom to top.

  • — Reverse direction. For axes in a 2-D view, the y-axis is vertical with values increasing from top to bottom.

Note

You cannot use these options with polar axes.

— Axes lines and background visibility
(default) |

Axes lines and background visibility, specified as either or . Specifying the visibility sets the property of the object or object to the specified value.

— Target axes
one or more axes

Target axes, specified as one or more axes. You can specify objects or objects. If you do not specify the axes, then sets the limits for the current axes ().

When you specify the axes, use single quotes around other input arguments that are character vectors.

Example:

Example:

Example:

Output Arguments

collapse all

— Current limit values
four-element vector | six-element vector

Current limit values, returned as a four-element or six-element vector.

  • For Cartesian axes in a 2-D view, is of the form . For axes in a 3-D view, is of the form . The , , and properties for the object store the limit values.

  • For polar axes, is of the form . The and properties for the object store the limit values.

Tips

  • You can combine multiple input arguments together, for example, . The options are evaluated from left to right. Subsequent options can overwrite properties set by prior ones.

  • If axes do not exist, the function creates them.

  • Use to keep plotting functions from overriding preset axis limits.

See Also

Functions

Properties

Introduced before R2006a

You have a modified version of this example. Do you want to open this example with your edits?

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.

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: .

Select web site

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Contact your local office

Sours: https://www.mathworks.com/help/matlab/ref/axis.html

Axis size matlab

Select a Web Site

Control Axes Layout

Axes Position-Related Properties

The  object has several properties that control the axes size and the layout of titles and axis labels within a figure.

  • — Outer boundary of the axes, including the title, labels, and a margin. Specify this property as a vector of the form . The and values indicate the distance from the lower left corner of the figure to the lower left corner of the outer boundary. The and values indicate the outer boundary dimensions.

  • — Boundary of the inner axes where plots appear, excluding the title, labels, and a margin. Specify this property as a vector of the form .

  • — Margins added to the width and height of the property values, specified as a vector of the form . This property is read-only. When you add axis labels and a title, MATLAB® updates the values to accommodate the text. The size of the boundary defined by the and properties includes all graph text.

  • — Position property preserved when the object changes size, specified as either or .

  • — Position units. The units must be set to (the default) to enable automatic axes resizing. When the position units are a unit of length, such as inches or centimeters, then the object is a fixed size.

Position and Margin Boundaries

This figure shows a 2-D view of the axes areas defined by the  values (red), the  values (blue), and the  expanded by the  values (magenta).

This figure shows a 3-D view of the axes areas defined by the  values (red), the  values (blue), and the  expanded by the  values (magenta).

Controlling Automatic Resize Behavior

Some scenarios can trigger the object to automatically resize. For example, interactively resizing the figure or adding a title or axis labels activates automatic resizing. Sometimes, the new axes size cannot satisfy both the and values, so the property indicates which values to preserve. Specify the property as one of these values:

  • — Preserve the value. Use this option when you do not want the axes or any of the surrounding text to extend beyond a certain outer boundary. MATLAB adjusts the size of the inner area of the axes (where plots appear) to try to fit the contents within the outer boundary.

  • — Preserve the value. Use this option when you want the inner area of the axes to remain a certain size within the figure. This option sometimes causes text to run off the figure.

Usually, leaving the property set to is preferable. However, an overly long axes title or labels can shrink the inner area of your axes to a size that is hard to read. In such a case, keeping the inner axes to a specific size can be preferable, even if the surrounding text runs off the figure.

For example, create a figure with two axes and specify the same width and height for each axes position. Set the property to for the upper axes and to for the lower axes. Notice that in the upper axes, the inner area shrinks to accommodate the text, but the text does not run outside the figure. In the lower axes, the size of the inner area is preserved, but some of the text is cut off.

Note

The following code uses the property, which is new starting in R2020a. If you are using an earlier release, set the to either or .

figure; ax1 = axes('Position',[0.13 0.58 0.77 0.34]); ax1.PositionConstraint = 'outerposition'; % R2019b and earlier: ax1.ActivePositionProperty = 'outerposition'; plot(ax1,1:10) title(ax1,'Preserve OuterPosition') yticklabels(ax1,{'My incredibly descriptive, excessively wordy, and overly long label',...'label 2','label 3'}) ax2 = axes('Position',[0.13 0.11 0.77 0.34]); ax2.PositionConstraint = 'innerposition'; % R2019b and earlier: ax2.ActivePositionProperty = 'position'; plot(ax2,1:10) title(ax2,'Preserve Position') yticklabels(ax2,{'My incredibly descriptive, excessively wordy, and overly long label',...'label 2','label 3'})

Stretch-to-Fill Behavior

By default, MATLAB stretches the axes to fill the available space. This “stretch-to-fill” behavior can cause some distortion. The axes might not exactly match the data aspect ratio, plot box aspect ratio, and camera-view angle values stored in the , , and properties. The “stretch-to-fill” behavior is enabled when the , , and properties of the object are set to .

If you specify the data aspect ratio, plot box aspect ratio, or camera-view angle, then the “stretch-to-fill” behavior is disabled. When the “stretch-to-fill” behavior is disabled, MATLAB makes the axes as large as possible within the available space and strictly adheres to the property values so that there is no distortion.

For example, this figure shows the same plot with and without the “stretch-to-fill” behavior enabled. The dotted line shows the available space as defined by the property. In both versions, the data aspect ratio, plot box aspect ratio, and camera-view angle values are the same. However, in the left plot, the stretching introduces some distortion.

Stretch-to-fill enabled (some distortion)Stretch-to-fill disabled (no distortion)

See Also

Functions

Properties

Related Topics

Sours: https://www.mathworks.com/help/matlab/creating_plots/automatic-axes-resize.html
Intro to MATLAB - Week 3 - Formatting plots (axes, title, legend)

This did not succeed, but instead she turned the fruit to one side and ran it several times to the right and left behind the cheek, into the. Space between the lips and teeth, and then again plunged the banana deep into her mouth, squeezed it slightly with her teeth and began to slowly pull it back, getting exquisite pleasure from the way her teeth leave deep, elongated grooves in his moist, odorous body.

But at some point she got tired of fighting her own lust and decisively bit the fruit in half.

You will also be interested:

Of light from the half-open door to the hall. There was a rustling sound in the room. I became alert and began to slowly approach the door. I heard my wife say in a muffled voice: Well, don't. Not worth it.



1698 1699 1700 1701 1702