Chart line appearance and behavior
expand all in page
Line
properties control the appearance and behavior of a Line
object. By changing property values, you can modify certain aspects of the line chart. Use dot notation to query and set properties.
p = plot(1:10);c = p.Color;p.Color = 'red';
Line
expand all
SeriesIndex
— Series index
positive whole number (default) | "none"
Series index, specified as a positive whole number or "none"
. This property is useful for reassigning the colors, line styles, or markers of Line
objects so that they match other objects.
By default, the SeriesIndex
property is a number that corresponds to the order in which the Line
object was created, starting at 1
. MATLAB uses the number to calculate indices for automatically assigning color, line style, or markers when you call plotting functions. The indices refer to the rows of the arrays stored in the ColorOrder
and LineStyleOrder
properties of the axes. Any objects in the axes that have the same SeriesIndex
number also have the same color (and line style and markers, if applicable).
A SeriesIndex
value of "none"
corresponds to a solid line with a neutral color that does not participate in the indexing scheme.
How Manually Setting Colors, Line Styles, or Markers Overrides SeriesIndex
Behavior
To manually control the color, line style, and markers, set the Color
, LineStyle
, and Marker
properties of the Line
object.
When you manually set these properties of an object, MATLAB disables automatic color, line style, and marker selection for that object and allows your selection to persist, regardless of the value of the SeriesIndex
property. The ColorMode
, LineStyleMode
, and MarkerMode
properties indicate whether the colors, line styles, and markers have been set manually (by you) or automatically. For each of these mode properties, a value of "manual"
indicates manual selection, and a value of "auto"
indicates automatic selection.
To enable automatic selection again, set the ColorMode
, LineStyleMode
, MarkerMode
, or all three properties to "auto"
, and set the SeriesIndex
property to a positive whole number.
In some cases, MATLAB sets the SeriesIndex
property to 0
, which also disables automatic selection.
Markers
expand all
Cartesian Coordinate Data
expand all
XData
— x values
vector
x values, specified as a vector.
For 2-D line plots, if you do not specify the x values, then MATLAB uses the indices of
YData
as the x values for the plot.XData
andYData
must have equal lengths.For 3-D line plots, if you do not specify the x values, then MATLAB uses the indices of
ZData
as the x values for the plot.XData
,YData
, andZData
must have equal lengths.
Example: [1:10]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| categorical
| datetime
| duration
XDataMode
— Control how XData
is set
'auto'
| 'manual'
Control how the XData
property is set, specified as one of these values:
'auto'
— MATLAB controls the value of theXData
property. TheXData
value can be:The indices of the values in
YData
.The values in a table variable. The
SourceTable
property specifies the table, and theXVariable
property specifies the variable. If either theSourceTable
orXVariable
properties are empty, theYData
indices are used.
'manual'
— TheXData
property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.
YData
— y values
vector
y values, specified as a vector. For 2-D line plots, XData
and YData
must have equal lengths. For 3-D line plots, XData
, YData
, and ZData
must have equal lengths.
Example: [1:10]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| categorical
| datetime
| duration
YDataMode
— Control how YData
is set
'auto'
| 'manual'
Control how the YData
property is set, specified as one of these values:
'auto'
— TheYData
property updates automatically based on theSourceTable
andYVariable
properties. This is the case when you pass a table to a plotting function.'manual'
— TheYData
property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.
ZData
— z values
vector
z values for the 3-D line plot, specified as a vector. XData
, YData
, and ZData
must have equal lengths.
Example: [1:10]
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| categorical
| datetime
| duration
ZDataMode
— Control how ZData
is set
'auto'
| 'manual'
Control how the ZData
property is set, specified as one of these values:
'auto'
— TheZData
property updates automatically based on theSourceTable
andZVariable
properties. This is the case when you pass a table to a plotting function.'manual'
— TheZData
property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.
AffectAutoLimits
— Include data range in axes limits
"on"
(default) | on/off logical value
Since R2023a
Include the Line
object's data range in the automatic selection of axes limits, specified as "on"
, "off"
, logical 1
(true
), or 0
(false
). The value is stored as an on/off logical value of type matlab.lang.OnOffSwitchState.
By default, the axes limits automatically change to include the data range for each successive line you create in the axes. Setting this property enables you to focus on the range of a subset of lines. To exclude the data range of a line in the automatic selection, set its AffectAutoLimits
property to "off"
.
Both lines have AffectAutoLimits="on" | Thin red line has AffectAutoLimits="off" |
---|---|
Polar Coordinate Data
expand all
ThetaData
— Angle values
vector
Angle values, specified as a vector. ThetaData
and RData
must be vectors of equal length.
This property applies only to lines in polar axes.
ThetaDataMode
— Control how ThetaData
is set
'auto'
| 'manual'
Control how the ThetaData
property is set, specified as one of these values:
'auto'
— MATLAB controls the value of theThetaData
property. The value can be:The indices of the values in
RData
.The values in a table variable. The
SourceTable
property specifies the table, and theThetaVariable
property specifies the variable. If either theSourceTable
orThetaVariable
properties are empty, theRData
indices are used.
'manual'
— TheThetaData
property is set directly and does not update automatically. This is the case when you pass coordinate values as vectors or matrices to a plotting function such aspolarplot
.
This property applies only to lines in polar axes.
ThetaDataSource
— Variable linked to ThetaData
''
(default) | character vector containing MATLAB workspace variable name
Variable linked to ThetaData
, specified as a character vector containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate the RData
.
By default, there is no linked variable so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the ThetaData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.
This property applies only to lines in polar axes.
RData
— Radius values
vector
Radius values, specified as a vector. ThetaData
and RData
must be vectors of equal length.
This property applies only to lines in polar axes.
RDataMode
— Control how RData
is set
'auto'
| 'manual'
Control how the RData
property is set, specified as one of these values:
'auto'
— TheRData
property updates automatically based on theSourceTable
andRVariable
properties. This is the case when you pass a table to a plotting function such aspolarplot
.'manual'
— TheRData
property is set directly and does not update automatically. This is the case when you pass coordinate values as vectors or matrices to a plotting function such aspolarplot
.This property applies only to lines in polar axes.
RDataSource
— Variable linked to RData
''
(default) | character vector containing MATLAB workspace variable name
Variable linked to RData
, specified as a character vector containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate the RData
.
By default, there is no linked variable so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the RData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.
This property applies only to lines in polar axes.
Geographic Coordinate Data
expand all
LatitudeData
— Latitude values
vector
Latitude values, specified as a vector. LatitudeData
and LongitudeData
must be vectors of equal length.
This property applies only to lines in geographic axes.
LatitudeDataMode
— Control how LatitudeData
is set
'auto'
| 'manual'
Control how the LatitudeData
property is set, specified as one of these values:
'auto'
— TheLatitudeData
property updates automatically based on theSourceTable
andLatitudeVariable
properties. This is the case when you pass a table to a plotting function.'manual'
— TheLatitudeData
property is set directly and does not update automatically. This is the case when you pass coordinate values as vectors or matrices to a plotting function.
This property applies only to geographic axes.
LatitudeDataSource
— Variable linked to LatitudeData
''
(default) | character vector containing MATLAB workspace variable name
Variable linked to LatitudeData
, specified as a character vector containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate LatitudeData
.
By default, there is no linked variable so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the LatitudeData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.
This property applies only to lines in geographic axes.
LongitudeData
— Longitude values
vector
Longitude values, specified as a vector. LongitudeData
and LatitudeData
must be vectors of equal length.
This property applies only to lines in geographic axes.
LongitudeDataMode
— Control how LongitudeData
is set
'auto'
| 'manual'
Control how the LongitudeData
property is set, specified as one of these values:
'auto'
— TheLongitudeData
property updates automatically based on theSourceTable
andLongitudeVariable
properties. This is the case when you pass a table to a plotting function.'manual'
— TheLongitudeData
property is set directly and does not update automatically. This is the case when you pass coordinate values as vectors or matrices to a plotting function.
This property applies only to geographic axes.
LongitudeDataSource
— Variable linked to LongitudeData
''
(default) | character vector containing MATLAB workspace variable name
Variable linked to LongitudeData
, specified as a character vector containing a MATLAB workspace variable name. MATLAB evaluates the variable in the base workspace to generate LongitudeData
.
By default, there is no linked variable so the value is an empty character vector, ''
. If you link a variable, then MATLAB does not update the LongitudeData
values immediately. To force an update of the data values, use the refreshdata function.
Note
If you change one data source property to a variable that contains data of a different dimension, you might cause the function to generate a warning and not render the graph until you have changed all data source properties to appropriate values.
This property applies only to lines in geographic axes.
Table Data (Since R2022a)
expand all
SourceTable
— Source table
table | timetable
Source table containing the data to plot. Specify this property as a table or a timetable.
XVariable
— Table variable containing x-coordinates
string scalar | character vector | pattern | numeric scalar | logical vector | vartype()
Table variable containing the x-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the XData
property.
This table lists the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
YVariable
— Table variable containing y-coordinates
string scalar | character vector | pattern | numeric scalar | logical vector | vartype()
Table variable containing the y-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the YData
property.
This table lists the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
ZVariable
— Table variable containing z-coordinates
string scalar | character vector | pattern | numeric scalar | logical vector | vartype()
Table variable containing the z-coordinates, specified using one of the indexing schemes from the following table. The variable you specify can contain numeric, categorical, datetime, or duration values. When you set this property, MATLAB updates the ZData
property.
This table lists the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
RVariable
— Table variable containing radius values
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()
Table variable containing the radius values for polar plots, specified using one of the indexing schemes from the following table. The variable you specify can contain any type of numeric values. When you set this property, MATLAB updates the RData
property. This property applies only to polar axes.
Here is a list of the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
ThetaVariable
— Table variable containing angle values
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()
Table variable containing the angle values for polar plots, specified using one of the indexing schemes from the following table. The variable you specify can contain any type of numeric values. When you set this property, MATLAB updates the ThetaData
property. This property applies only to polar axes.
Here is a list of the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
LatitudeVariable
— Table variable containing latitude values
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()
Table variable containing the latitude values for geographic plots, specified using one of the indexing schemes from the following table. When you set this property, MATLAB updates the LatitudeData
property. This property applies only to geographic axes.
Here is a list of the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
LongitudeVariable
— Table variable containing longitude values
string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype()
Table variable containing the longitude values for geographic plots, specified using one of the indexing schemes from the following table. When you set this property, MATLAB updates the LongitudeData
property. This property applies only to geographic axes.
Here is a list of the different indexing schemes you can use to specify the table variable.
Indexing Scheme | Examples |
---|---|
Variable name:
|
|
Variable index:
|
|
Variable type:
|
|
Legend
expand all
Interactivity
expand all
DataTipTemplate
— Data tip content
DataTipTemplate
object
Data tip content, specified as a DataTipTemplate
object. You can control the content that appears in a data tip by modifying the properties of the underlying DataTipTemplate
object. For a list of properties, see DataTipTemplate Properties.
For an example of modifying data tips, see Create Custom Data Tips.
Note
The DataTipTemplate
object is not returned by findobj
or findall
, and it is not copied by copyobj
.
Callbacks
expand all
Callback Execution Control
expand all
Parent/Child
expand all
Parent
— Parent
Axes
object | PolarAxes
object | Group
object | Transform
object
Parent, specified as an Axes
, PolarAxes
, Group
, or Transform
object.
Identifiers
expand all
Type
— Type of graphics object
'line'
This property is read-only.
Type of graphics object, returned as 'line'
. Use this property to find all objects of a given type within a plotting hierarchy, for example, searching for the type using findobj.
Version History
Introduced before R2006a
expand all
R2023b: Opt out of automatic color and line style selection with SeriesIndex="none"
Opt out of automatic color and line style selection for Line
objects by setting the SeriesIndex
property to "none"
. When you specify "none"
, the Line
object has a solid line style and a neutral color with no markers.
To enable automatic selection again, set the SeriesIndex
property to a positive whole number.
R2023a: Control whether a line affects the automatic calculation of the axes limits with the AffectAutoLimits
property
Specify whether a specific line affects the automatically selected axes limits by setting the AffectAutoLimits
property. By default, the axes limits change to encompass the data range for each successive line you create. Setting this property enables you to focus on the range of a subset of lines in the axes.
R2022a: Modify plots created from tables using properties such as SourceTable
, XVariable
, YVariable
, and ZVariable
Modify plots created with table data using the SourceTable
, XVariable
, YVarlable
, and ZVariable
properties.
For polar plots, you can update the data variables with the RVariable
and ThetaVariable
properties.
For geographic plots, you can update the data variables with the LatitudeVariable
and LongitudeVariable
properties.
These additional properties control how MATLAB manages your data: YDataMode
, ZDataMode
, RDataMode
, LatitudeDataMode
, and LongitudeDataMode
.
R2020a: Control automatic color and line style selection with the SeriesIndex
property
Set the SeriesIndex
property of any Line
object to control how the objects vary in color, line style, and marker symbol. Changing the value of this property is useful when you want to match the colors, line styles, and markers of different objects in the axes.
R2020a: UIContextMenu
property is not recommended
Setting or getting UIContextMenu
property is not recommended. Instead, use the ContextMenu
property, which accepts the same type of input and behaves the same way as the UIContextMenu
property.
There are no plans to remove the UIContextMenu
property, but it is no longer listed when you call the set
, get
, or properties
functions on the Line
object.
See Also
plot | polarplot | plot3 | semilogx | semilogy | loglog
Topics
- Access Property Values
- Graphics Object Properties
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