Chart line appearance and behavior (2024)

Table of Contents
Line SeriesIndex — Series index positive whole number (default) | "none" Markers Cartesian Coordinate Data XData — x values vector XDataMode — Control how XData is set 'auto' | 'manual' YData — y values vector YDataMode — Control how YData is set 'auto' | 'manual' ZData — z values vector ZDataMode — Control how ZData is set 'auto' | 'manual' AffectAutoLimits — Include data range in axes limits "on" (default) | on/off logical value Polar Coordinate Data ThetaData — Angle values vector ThetaDataMode — Control how ThetaData is set 'auto' | 'manual' ThetaDataSource — Variable linked to ThetaData '' (default) | character vector containing MATLAB workspace variable name RData — Radius values vector RDataMode — Control how RData is set 'auto' | 'manual' RDataSource — Variable linked to RData '' (default) | character vector containing MATLAB workspace variable name Geographic Coordinate Data LatitudeData — Latitude values vector LatitudeDataMode — Control how LatitudeData is set 'auto' | 'manual' LatitudeDataSource — Variable linked to LatitudeData '' (default) | character vector containing MATLAB workspace variable name LongitudeData — Longitude values vector LongitudeDataMode — Control how LongitudeData is set 'auto' | 'manual' LongitudeDataSource — Variable linked to LongitudeData '' (default) | character vector containing MATLAB workspace variable name Table Data (Since R2022a) SourceTable — Source table table | timetable XVariable — Table variable containing x-coordinates string scalar | character vector | pattern | numeric scalar | logical vector | vartype() YVariable — Table variable containing y-coordinates string scalar | character vector | pattern | numeric scalar | logical vector | vartype() ZVariable — Table variable containing z-coordinates string scalar | character vector | pattern | numeric scalar | logical vector | vartype() RVariable — Table variable containing radius values string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype() ThetaVariable — Table variable containing angle values string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype() LatitudeVariable — Table variable containing latitude values string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype() LongitudeVariable — Table variable containing longitude values string array | character vector | cell array | pattern | numeric scalar or vector | logical vector | vartype() Legend Interactivity DataTipTemplate — Data tip content DataTipTemplate object Callbacks Callback Execution Control Parent/Child Parent — Parent Axes object | PolarAxes object | Group object | Transform object Identifiers Type — Type of graphics object 'line' Version History R2023b: Opt out of automatic color and line style selection with SeriesIndex="none" R2023a: Control whether a line affects the automatic calculation of the axes limits with the AffectAutoLimits property R2022a: Modify plots created from tables using properties such as SourceTable, XVariable, YVariable, and ZVariable R2020a: Control automatic color and line style selection with the SeriesIndex property R2020a: UIContextMenu property is not recommended See Also Topics MATLAB Command Americas Europe Asia Pacific References

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

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

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 and YData 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, and ZData must have equal lengths.

Example: [1:10]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | categorical | datetime | duration

Control how the XData property is set, specified as one of these values:

  • 'auto' — MATLAB controls the value of the XData property. The XData value can be:

    • The indices of the values in YData.

    • The values in a table variable. The SourceTable property specifies the table, and the XVariable property specifies the variable. If either the SourceTable or XVariable properties are empty, the YData indices are used.

  • 'manual' — The XData property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.

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

Control how the YData property is set, specified as one of these values:

  • 'auto' — The YData property updates automatically based on the SourceTable and YVariable properties. This is the case when you pass a table to a plotting function.

  • 'manual' — The YData property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.

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

Control how the ZData property is set, specified as one of these values:

  • 'auto' — The ZData property updates automatically based on the SourceTable and ZVariable properties. This is the case when you pass a table to a plotting function.

  • 'manual' — The ZData property is set directly and does not update automatically. This is the case when you plot vectors or matrices of coordinates.

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"

Chart line appearance and behavior (1)

Chart line appearance and behavior (2)

Polar Coordinate Data

expand all

Angle values, specified as a vector. ThetaData and RData must be vectors of equal length.

This property applies only to lines in polar axes.

Control how the ThetaData property is set, specified as one of these values:

  • 'auto' — MATLAB controls the value of the ThetaData 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 the ThetaVariable property specifies the variable. If either the SourceTable or ThetaVariable properties are empty, the RData indices are used.

  • 'manual' — The ThetaData 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 as polarplot.

This property applies only to lines in polar axes.

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.

Radius values, specified as a vector. ThetaData and RData must be vectors of equal length.

This property applies only to lines in polar axes.

Control how the RData property is set, specified as one of these values:

  • 'auto' — The RData property updates automatically based on the SourceTable and RVariable properties. This is the case when you pass a table to a plotting function such as polarplot.

  • 'manual' — The RData 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 as polarplot.

    This property applies only to lines in polar axes.

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

Latitude values, specified as a vector. LatitudeData and LongitudeData must be vectors of equal length.

This property applies only to lines in geographic axes.

Control how the LatitudeData property is set, specified as one of these values:

  • 'auto' — The LatitudeData property updates automatically based on the SourceTable and LatitudeVariable properties. This is the case when you pass a table to a plotting function.

  • 'manual' — The LatitudeData 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.

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.

Longitude values, specified as a vector. LongitudeData and LatitudeData must be vectors of equal length.

This property applies only to lines in geographic axes.

Control how the LongitudeData property is set, specified as one of these values:

  • 'auto' — The LongitudeData property updates automatically based on the SourceTable and LongitudeVariable properties. This is the case when you pass a table to a plotting function.

  • 'manual' — The LongitudeData 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.

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

Source table containing the data to plot. Specify this property as a table or a timetable.

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

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 SchemeExamples

Variable name:

  • A string scalar or character vector.

  • A pattern object. The pattern object must refer to only one variable.

  • "A" or 'A' — A variable named A

  • "Var"+digitsPattern(1) — The variable with the name "Var" followed by a single digit

Variable index:

  • An index number that refers to the location of a variable in the table.

  • A logical vector. Typically, this vector is the same length as the number of variables, but you can omit trailing 0 or false values.

  • 3 — The third variable from the table

  • [false false true] — The third variable

Variable type:

  • A vartype subscript that selects a table variable of a specified type. The subscript must refer to only one variable.

  • vartype("double") — The variable containing double values

Legend

expand all

Interactivity

expand all

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, specified as an Axes, PolarAxes, Group, or Transform object.

Identifiers

expand all

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

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.

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.

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.

Chart line appearance and behavior (3)

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)

Asia Pacific

Contact your local office

Chart line appearance and behavior (2024)

References

Top Articles
Latest Posts
Article information

Author: Golda Nolan II

Last Updated:

Views: 6625

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Golda Nolan II

Birthday: 1998-05-14

Address: Suite 369 9754 Roberts Pines, West Benitaburgh, NM 69180-7958

Phone: +522993866487

Job: Sales Executive

Hobby: Worldbuilding, Shopping, Quilting, Cooking, Homebrewing, Leather crafting, Pet

Introduction: My name is Golda Nolan II, I am a thoughtful, clever, cute, jolly, brave, powerful, splendid person who loves writing and wants to share my knowledge and understanding with you.