Graph plot appearance and behavior
GraphPlot
properties control the appearance and behavior of
plotted graphs. By changing property values, you can modify aspects of the graph display. Use dot
notation to refer to a particular object and property:
G = graph([1 1 1 1 5 5 5 5],[2 3 4 5 6 7 8 9]); h = plot(G); c = h.EdgeColor; h.EdgeColor = 'k';
NodeColor
— Node color[0 0.4470 0.7410]
(default) | RGB triplet | hexadecimal color code | color name | matrix | 'flat'
| 'none'
Node color, specified as one of these values:
'none'
— Nodes are not drawn.
'flat'
— Color of each node depends on the value of
NodeCData
.
matrix — Each row is an RGB triplet representing the color of one node. The size
of the matrix is numnodes(G)
-by-3
.
RGB triplet, hexadecimal color code, or color name — All nodes use the specified color.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
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 [0,1]
; for example, [0.4 0.6
0.7]
.
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 0
to F
. The
values are not case sensitive. Thus, the color codes
'#FF8800'
, '#ff8800'
,
'#F80'
, and '#f80'
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 Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
'red' | 'r' | [1 0 0] | '#FF0000' | |
'green' | 'g' | [0 1 0] | '#00FF00' | |
'blue' | 'b' | [0 0 1] | '#0000FF' | |
'cyan' | 'c' | [0 1 1] | '#00FFFF' | |
'magenta' | 'm' | [1 0 1] | '#FF00FF' | |
'yellow' | 'y' | [1 1 0] | '#FFFF00' | |
'black' | 'k' | [0 0 0] | '#000000' | |
'white' | 'w' | [1 1 1] | '#FFFFFF' |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB® uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | '#0072BD' | |
[0.8500 0.3250 0.0980] | '#D95319' | |
[0.9290 0.6940 0.1250] | '#EDB120' | |
[0.4940 0.1840 0.5560] | '#7E2F8E' | |
[0.4660 0.6740 0.1880] | '#77AC30' | |
[0.3010 0.7450 0.9330] | '#4DBEEE' | |
[0.6350 0.0780 0.1840] | '#A2142F' |
Example: plot(G,'NodeColor','k')
creates a graph plot with black
nodes.
Marker
— Node marker symbol'o'
(default) | character vector | cell array | string vectorNode marker symbol, specified as one of the values listed in this table, or as a cell array or string vector of such values. The default is to use circular markers for the graph nodes. Specify a cell array of character vectors or string vector to use different markers for each node.
Value | Description |
---|---|
'o' | Circle |
'+' | Plus sign |
'*' | Asterisk |
'.' | Point |
'x' | Cross |
'square' or 's' | Square |
'diamond' or 'd' | Diamond |
'^' | Upward-pointing triangle |
'v' | Downward-pointing triangle |
'>' | Right-pointing triangle |
'<' | Left-pointing triangle |
'pentagram' or 'p' | Five-pointed star (pentagram) |
'hexagram' or 'h' | Six-pointed star (hexagram) |
'none' | No markers |
Example: '+'
Example: 'diamond'
MarkerSize
— Node marker sizeNode marker size, specified as a positive value in point units or as a vector of such
values. Specify a vector to use different marker sizes for each node in the graph. The default
value of MarkerSize
is 4 for graphs with 100 or fewer nodes, and
2
for graphs with more than 100 nodes.
Example: 10
NodeCData
— Color data of node markersColor data of node markers, specified as a vector with length equal to the number of
nodes in the graph. The values in NodeCData
map linearly to the colors in
the current colormap, resulting in different colors for each node in the plotted graph.
EdgeColor
— Edge color[0 0.4470 0.7410]
(default) | RGB triplet | hexadecimal color code | color name | matrix | 'flat'
| 'none'
Edge color, specified as one of these values:
'none'
— Edges are not drawn.
'flat'
— Color of each edge depends on the value of
EdgeCData
.
matrix — Each row is an RGB triplet representing the color of one edge. The size
of the matrix is numedges(G)
-by-3
.
RGB triplet, hexadecimal color code, or color name — All edges use the specified color.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
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 [0,1]
; for example, [0.4 0.6
0.7]
.
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 0
to F
. The
values are not case sensitive. Thus, the color codes
'#FF8800'
, '#ff8800'
,
'#F80'
, and '#f80'
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 Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
'red' | 'r' | [1 0 0] | '#FF0000' | |
'green' | 'g' | [0 1 0] | '#00FF00' | |
'blue' | 'b' | [0 0 1] | '#0000FF' | |
'cyan' | 'c' | [0 1 1] | '#00FFFF' | |
'magenta' | 'm' | [1 0 1] | '#FF00FF' | |
'yellow' | 'y' | [1 1 0] | '#FFFF00' | |
'black' | 'k' | [0 0 0] | '#000000' | |
'white' | 'w' | [1 1 1] | '#FFFFFF' |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | '#0072BD' | |
[0.8500 0.3250 0.0980] | '#D95319' | |
[0.9290 0.6940 0.1250] | '#EDB120' | |
[0.4940 0.1840 0.5560] | '#7E2F8E' | |
[0.4660 0.6740 0.1880] | '#77AC30' | |
[0.3010 0.7450 0.9330] | '#4DBEEE' | |
[0.6350 0.0780 0.1840] | '#A2142F' |
Example: plot(G,'EdgeColor','r')
creates a graph plot with red
edges.
LineStyle
— Line style'-'
(default) | '--'
| ':'
| '-.'
| 'none'
| cell array | string vectorLine style, specified as one of the line styles listed in this table, or as a cell array or string vector of such values. Specify a cell array of character vectors or string vector to use different line styles for each edge.
Character(s) | Line Style | Resulting Line |
---|---|---|
'-' | Solid line |
|
'--' | Dashed line |
|
':' | Dotted line |
|
'-.' | Dash-dotted line |
|
'none' | No line | No line |
LineWidth
— Edge line width0.5
(default) | positive value | vectorEdge line width, specified as a positive value in point units, or as a vector of such values. Specify a vector to use a different line width for each edge in the graph.
Example: 0.75
EdgeAlpha
— Transparency of graph edges0.5
(default) | scalar value between 0
and 1
inclusiveTransparency of graph edges, specified as a scalar value between 0
and
1
inclusive. A value of 1
means fully opaque and
0
means completely transparent (invisible).
Example: 0.25
EdgeCData
— Color data of edge linesColor data of edge lines, specified as a vector with length equal to the number of edges
in the graph. The values in EdgeCData
map linearly to the colors in the
current colormap, resulting in different colors for each edge in the plotted graph.
ArrowSize
— Arrow sizeArrow size, specified as a positive value in point units or as a vector of such values.
As a vector, ArrowSize
specifies the size of the arrow for each edge in the
graph. The default value of ArrowSize
is 7
for graphs
with 100 or fewer nodes, and 4
for graphs with more than 100 nodes.
ArrowSize
only affects directed graphs.
Example: 15
ArrowPosition
— Position of arrow along edge0.5
(default) | scalar | vectorPosition of arrow along edge, specified as a value in the range [0 1]
or as a vector of such values with length equal to the number of edges. A value near 0 places
arrows closer to the source node, and a value near 1 places arrows closer to the target node.
The default value is 0.5
so that the arrows are halfway between the source
and target nodes.
ArrowPosition
only affects directed graphs.
ShowArrows
— Toggle display of arrows on directed edgesToggle display of arrows on directed edges, specified as 'off'
or
'on'
, or as numeric or logical 1
(true
) or 0
(false
). A value of
'on'
is equivalent to true
, and
'off'
is equivalent to false
. 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 matlab.lang.OnOffSwitchState
.
For directed graphs the default value is 'on'
so that arrows are
displayed, but you can specify a value of 'off'
to hide the arrows on the
directed edges. For undirected graphs ShowArrows
is always
'off'
.
XData
— x-coordinate of nodesXData
and YData
must be specified together so that
each node has a valid (x,y) coordinate. Optionally, you
can specify ZData
for 3-D coordinates.
x-coordinate of nodes, specified as a vector with length equal to the number of nodes in the graph.
YData
— y-coordinate of nodesXData
and YData
must be specified together so that
each node has a valid (x,y) coordinate. Optionally, you
can specify ZData
for 3-D coordinates.
y-coordinate of nodes, specified as a vector with length equal to the number of nodes in the graph.
ZData
— z-coordinate of nodesXData
and YData
must be specified together so that
each node has a valid (x,y) coordinate. Optionally, you
can specify ZData
for 3-D coordinates.
z-coordinate of nodes, specified as a vector with length equal to the number of nodes in the graph.
NodeLabel
— Node labelsNode labels, specified as a numeric vector or cell array of character vectors. The length
of NodeLabel
must be equal to the number of nodes in the graph. By default
NodeLabel
is a cell array containing the node IDs for the graph
nodes:
For nodes without names (that is, G.Nodes
does not contain a
Name
variable), the node labels are the values
unique(G.Edges.EndNodes)
contained in a cell array.
For named nodes, the node labels are G.Nodes.Name'
.
Example: {'A', 'B', 'C'}
Example: [1 2 3]
Example: plot(G,'NodeLabels',G.Nodes.Name)
labels the nodes with their
names.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| cell
NodeLabelMode
— Selection mode for node labels'auto'
(default) | 'manual'
Selection mode for node labels, specified as 'auto'
(default) or
'manual'
. Specify NodeLabelMode
as
'auto'
to populate NodeLabel
with the node IDs for the
graph nodes (numeric node indices or node names). Specifying NodeLabelMode
as 'manual'
does not change the values in
NodeLabel
.
NodeLabelColor
— Color of node labels[0 0 0]
(default) | RGB triplet | hexadecimal color code | color name | matrixNode label color, specified as one of these values:
matrix — Each row is an RGB triplet representing the color of one node label.
The size of the matrix is numnodes(G)
-by-3
.
RGB triplet, hexadecimal color code, or color name — All node labels use the specified color.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
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 [0,1]
; for example, [0.4 0.6
0.7]
.
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 0
to F
. The
values are not case sensitive. Thus, the color codes
'#FF8800'
, '#ff8800'
,
'#F80'
, and '#f80'
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 Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
'red' | 'r' | [1 0 0] | '#FF0000' | |
'green' | 'g' | [0 1 0] | '#00FF00' | |
'blue' | 'b' | [0 0 1] | '#0000FF' | |
'cyan' | 'c' | [0 1 1] | '#00FFFF' | |
'magenta' | 'm' | [1 0 1] | '#FF00FF' | |
'yellow' | 'y' | [1 1 0] | '#FFFF00' | |
'black' | 'k' | [0 0 0] | '#000000' | |
'white' | 'w' | [1 1 1] | '#FFFFFF' |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | '#0072BD' | |
[0.8500 0.3250 0.0980] | '#D95319' | |
[0.9290 0.6940 0.1250] | '#EDB120' | |
[0.4940 0.1840 0.5560] | '#7E2F8E' | |
[0.4660 0.6740 0.1880] | '#77AC30' | |
[0.3010 0.7450 0.9330] | '#4DBEEE' | |
[0.6350 0.0780 0.1840] | '#A2142F' |
Example: plot(G,'NodeLabel',C,'NodeLabelColor','m')
creates a graph
plot with magenta node labels.
EdgeLabel
— Edge labels{}
(default) | vector | cell array of character vectorsEdge labels, specified as a numeric vector or cell array of character vectors. The length
of EdgeLabel
must be equal to the number of edges in the graph. By default
EdgeLabel
is an empty cell array (no edge labels are displayed).
Example: {'A', 'B', 'C'}
Example: [1 2 3]
Example: plot(G,'EdgeLabels',G.Edges.Weight)
labels the graph edges
with their weights.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| cell
EdgeLabelMode
— Selection mode for edge labels'manual'
(default) | 'auto'
Selection mode for edge labels, specified as 'manual'
(default) or
'auto'
. Specify EdgeLabelMode
as
'auto'
to populate EdgeLabel
with the edge weights in
G.Edges.Weight
(if available), or the edge indices
G.Edges(k,:)
(if no weights are available). Specifying
EdgeLabelMode
as 'manual'
does not change the values in
EdgeLabel
.
EdgeLabelColor
— Color of edge labels[0 0 0]
(default) | RGB triplet | hexadecimal color code | color name | matrixEdge label color, specified as one of these values:
matrix — Each row is an RGB triplet representing the color of one edge label.
The size of the matrix is numedges(G)
-by-3
.
RGB triplet, hexadecimal color code, or color name — All edge labels use the specified color.
RGB triplets and hexadecimal color codes are useful for specifying custom colors.
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 [0,1]
; for example, [0.4 0.6
0.7]
.
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 0
to F
. The
values are not case sensitive. Thus, the color codes
'#FF8800'
, '#ff8800'
,
'#F80'
, and '#f80'
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 Name | Short Name | RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|---|---|
'red' | 'r' | [1 0 0] | '#FF0000' | |
'green' | 'g' | [0 1 0] | '#00FF00' | |
'blue' | 'b' | [0 0 1] | '#0000FF' | |
'cyan' | 'c' | [0 1 1] | '#00FFFF' | |
'magenta' | 'm' | [1 0 1] | '#FF00FF' | |
'yellow' | 'y' | [1 1 0] | '#FFFF00' | |
'black' | 'k' | [0 0 0] | '#000000' | |
'white' | 'w' | [1 1 1] | '#FFFFFF' |
Here are the RGB triplets and hexadecimal color codes for the default colors MATLAB uses in many types of plots.
RGB Triplet | Hexadecimal Color Code | Appearance |
---|---|---|
[0 0.4470 0.7410] | '#0072BD' | |
[0.8500 0.3250 0.0980] | '#D95319' | |
[0.9290 0.6940 0.1250] | '#EDB120' | |
[0.4940 0.1840 0.5560] | '#7E2F8E' | |
[0.4660 0.6740 0.1880] | '#77AC30' | |
[0.3010 0.7450 0.9330] | '#4DBEEE' | |
[0.6350 0.0780 0.1840] | '#A2142F' |
Example: plot(G,'EdgeLabel',C,'EdgeLabelColor','m')
creates a graph
plot with magenta edge labels.
Interpreter
— Interpretation of text characters'tex'
(default) | 'latex'
| 'none'
Interpretation of text characters, specified as one of these values:
'tex'
— Interpret characters using a subset of TeX
markup.
'latex'
— Interpret characters using LaTeX markup.
'none'
— Display literal characters.
By default, MATLAB supports a subset of TeX markup. Use TeX markup to add superscripts and subscripts, modify the font type and color, and include special characters in the text.
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 'tex'
,
the supported modifiers are as follows.
Modifier | Description | Example |
---|---|---|
^{ } | Superscript | 'text^{superscript}' |
_{ } | Subscript | 'text_{subscript}' |
\bf | Bold font | '\bf text' |
\it | Italic font | '\it text' |
\sl | Oblique font (usually the same as italic font) | '\sl text' |
\rm | Normal font | '\rm text' |
\fontname{ | Font name — Replace
with the name of
a font family. You can use this in combination with other modifiers. | '\fontname{Courier} text' |
\fontsize{ | Font size —Replace
with a numeric
scalar value in point units. | '\fontsize{15} text' |
\color{ | Font color — Replace
with one of
these colors: red , green ,
yellow , magenta ,
blue , black ,
white , gray ,
darkGreen , orange , or
lightBlue . | '\color{magenta} text' |
\color[rgb]{specifier} | Custom font color — Replace
with a
three-element RGB triplet. | '\color[rgb]{0,0.5,0.5} text' |
This table lists the supported special characters for the
'tex'
interpreter.
Character Sequence | Symbol | Character Sequence | Symbol | Character Sequence | Symbol |
---|---|---|---|---|---|
| α |
| υ |
| ~ |
| ∠ |
|
| ≤ | |
|
|
| χ |
| ∞ |
| β |
| ψ |
| ♣ |
| γ |
| ω |
| ♦ |
| δ |
| Γ |
| ♥ |
| ϵ |
| Δ |
| ♠ |
| ζ |
| Θ |
| ↔ |
| η |
| Λ |
| ← |
| θ |
| Ξ |
| ⇐ |
| ϑ |
| Π |
| ↑ |
| ι |
| Σ |
| → |
| κ |
| ϒ |
| ⇒ |
| λ |
| Φ |
| ↓ |
| µ |
| Ψ |
| º |
| ν |
| Ω |
| ± |
| ξ |
| ∀ |
| ≥ |
| π |
| ∃ |
| ∝ |
| ρ |
| ∍ |
| ∂ |
| σ |
| ≅ |
| • |
| ς |
| ≈ |
| ÷ |
| τ |
| ℜ |
| ≠ |
| ≡ |
| ⊕ |
| ℵ |
| ℑ |
| ∪ |
| ℘ |
| ⊗ |
| ⊆ |
| ∅ |
| ∩ |
| ∈ |
| ⊇ |
| ⊃ |
| ⌈ |
| ⊂ |
| ∫ |
| · |
| ο |
| ⌋ |
| ¬ |
| ∇ |
| ⌊ |
| x |
| ... |
| ⊥ |
| √ |
| ´ |
| ∧ |
| ϖ |
| ∅ |
| ⌉ |
| 〉 |
| | |
| ∨ |
| 〈 |
| © |
To use LaTeX markup, set the Interpreter
property to
'latex'
. Use dollar symbols around the text, for example, use
'$\int_1^{20} x^2 dx$'
for inline mode or '$$\int_1^{20} x^2
dx$$'
for display mode.
The displayed text uses the default LaTeX font style. The FontName
,
FontWeight
, and FontAngle
properties do not have an
effect. To change the font style, use LaTeX markup.
The maximum size of the text that you can use with the LaTeX interpreter is 1200 characters.
For more information about the LaTeX system, see The LaTeX Project website at https://www.latex-project.org/.
NodeFontName
— Font name for node labels'Helvetica'
(default) | supported font name | 'FixedWidth'
Font name for node labels, specified as a supported font name or
'FixedWidth'
. For labels to display and print properly, you must choose a
font that your system supports. The default font depends on the specific operating system and
locale. For example, Windows® and Linux®systems in English localization use the Helvetica font by default.
To use a fixed-width font that looks good in any locale, specify
'FixedWidth'
.
Example: 'Cambria'
NodeFontSize
— Font size for node labels8
(default) | positive number | vector of positive numbersFont size for node labels, specified as a positive number or a vector of positive
numbers. If NodeFontSize
is a vector, then each element specifies the font
size of one node label.
NodeFontWeight
— Thickness of text in node labels'normal'
(default) | 'bold'
| vector | cell arrayThickness of text in node labels, specified as 'normal'
,
'bold'
, or as a string vector or cell array of character vectors
specifying 'normal'
or 'bold'
for each node.
'bold'
— Thicker character outlines than
normal
'normal'
— Normal weight as defined by the particular font
Not all fonts have a bold font weight.
Data Types: cell
| char
| string
NodeFontAngle
— Character slant of text in node labels'normal'
(default) | 'italic'
| vector | cell arrayCharacter slant of text in node labels, specified as 'normal'
,
'italic'
, or as a string vector or cell array of character vectors
specifying 'normal'
or 'italic'
for each node.
'italic'
— Slanted characters
'normal'
— No character slant
Not all fonts have both font styles.
Data Types: cell
| char
| string
EdgeFontName
— Font name for edge labels'Helvetica'
(default) | supported font name | 'FixedWidth'
Font name for edge labels, specified as a supported font name or
'FixedWidth'
. For labels to display and print properly, you must choose a
font that your system supports. The default font depends on the specific operating system and
locale. For example, Windows and Linuxsystems in English localization use the Helvetica font by default.
To use a fixed-width font that looks good in any locale, specify
'FixedWidth'
.
Example: 'Cambria'
EdgeFontSize
— Font size for edge labels8
(default) | positive number | vector of positive numbersFont size for edge labels, specified as a positive number or a vector of positive
numbers. If EdgeFontSize
is a vector, then each element specifies the font
size of one edge label.
EdgeFontWeight
— Thickness of text in edge labels'normal'
(default) | 'bold'
| vector | cell arrayThickness of text in edge labels, specified as 'normal'
,
'bold'
, or as a string vector or cell array of character vectors
specifying 'normal'
or 'bold'
for each edge.
'bold'
— Thicker character outlines than
normal
'normal'
— Normal weight as defined by the particular font
Not all fonts have a bold font weight.
Data Types: cell
| char
| string
EdgeFontAngle
— Character slant of text in edge labels'normal'
(default) | 'italic'
| vector | cell arrayCharacter slant of text in edge labels, specified as 'normal'
,
'italic'
, or as a string vector or cell array of character vectors
specifying 'normal'
or 'italic'
for each edge.
'italic'
— Slanted characters
'normal'
— No character slant
Not all fonts have both font styles.
Data Types: cell
| char
| string
DisplayName
— Text used by legend''
(default) | character vectorText used by the legend, specified as a character vector. The text appears next to an icon of the GraphPlot.
Example: 'Text Description'
For multiline text, create the character vector using sprintf
with the
new line character \n
.
Example: sprintf('line one\nline two')
Alternatively, you can specify the legend text using the legend
function.
If you specify the text as an input argument to the legend
function, then the legend uses the specified text and sets the
DisplayName
property to the same value.
If you do not specify the text as an input argument to the legend
function, then the legend uses the text in the
DisplayName
property. If the DisplayName
property
does not contain any text, then the legend generates a character vector. The character
vector has the form 'dataN'
, where N
is the number
assigned to the GraphPlot object based on its location in the list of
legend entries.
If you edit interactively the character vector in an existing legend, then MATLAB updates the DisplayName
property to the edited character
vector.
Annotation
— Legend icon display styleAnnotation
objectThis property is read-only.
Legend icon display style, returned as an Annotation
object. Use this
object to include or exclude the GraphPlot from a legend.
Query the Annotation
property to get the
Annotation
object.
Query the LegendInformation
property of the
Annotation
object to get the LegendEntry
object.
Specify the IconDisplayStyle
property of the
LegendEntry
object to one of these values:
'on'
— Include the GraphPlot object in
the legend as one entry (default).
'off'
— Do not include the GraphPlot
object in the legend.
'children'
— Include only children of the GraphPlot object as separate entries in the legend.
If a legend already exists and you change the
IconDisplayStyle
setting, then you must call legend
to
update the display.
Visible
— State of visibility'on'
(default) | on/off logical valueState of visibility, specified as 'on'
or 'off'
, or as
numeric or logical 1
(true
) or
0
(false
). A value of 'on'
is equivalent to true
, and 'off'
is equivalent to
false
. 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 matlab.lang.OnOffSwitchState
.
'on'
— Display the object.
'off'
— Hide the object without deleting it. You
still can access the properties of an invisible object.
DataTipTemplate
— Data tip contentDataTipTemplate
objectData 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.
The DataTipTemplate
object is not returned by
findobj
or findall
, and it is not
copied by copyobj
.
ContextMenu
— Context menuGraphicsPlaceholder
array (default) | ContextMenu
objectContext menu, specified as a ContextMenu
object. Use this property
to display a context menu when you right-click the object. Create the context menu using
the uicontextmenu
function.
If the PickableParts
property is set to
'none'
or if the HitTest
property is set
to 'off'
, then the context menu does not appear.
Selected
— Selection state'off'
(default) | on/off logical valueSelection state, specified as 'on'
or 'off'
, or as
numeric or logical 1
(true
) or
0
(false
). A value of 'on'
is equivalent to true, and 'off'
is equivalent to
false
. 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 matlab.lang.OnOffSwitchState
.
'on'
— Selected. If you click the object when in
plot edit mode, then MATLAB sets its Selected
property to
'on'
. If the SelectionHighlight
property also is set to 'on'
, then MATLAB displays selection handles around the object.
'off'
— Not selected.
SelectionHighlight
— Display of selection handles'on'
(default) | on/off logical valueDisplay of selection handles when selected, specified as 'on'
or
'off'
, or as numeric or logical 1
(true
) or 0
(false
). A
value of 'on'
is equivalent to true, and 'off'
is
equivalent to false
. 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 matlab.lang.OnOffSwitchState
.
'on'
— Display selection handles when the
Selected
property is set to
'on'
.
'off'
— Never display selection handles, even
when the Selected
property is set to
'on'
.
ButtonDownFcn
— Mouse-click callback''
(default) | function handle | cell array | character vectorMouse-click callback, specified as one of these values:
Function handle
Cell array containing a function handle and additional arguments
Character vector that is a valid MATLAB command or function, which is evaluated in the base workspace (not recommended)
Use this property to execute code when you click the GraphPlot. If you specify this property using a function handle, then MATLAB passes two arguments to the callback function when executing the callback:
The GraphPlot object — You can access properties of the GraphPlot object from within the callback function.
Event data — This argument is empty for this property. Replace it with the
tilde character (~
) in the function definition to indicate that this
argument is not used.
For more information on how to use function handles to define callback functions, see Callback Definition.
If the PickableParts
property is set to 'none'
or if the HitTest
property is set to 'off'
, then this
callback does not execute.
Example: @myCallback
Example: {@myCallback,arg3}
CreateFcn
— Creation callback''
(default) | function handle | cell array | character vectorCreation callback, specified as one of these values:
Function handle
Cell array containing a function handle and additional arguments
Character vector that is a valid MATLAB command or function, which is evaluated in the base workspace (not recommended)
Use this property to execute code when you create the GraphPlot.
Setting the CreateFcn
property on an existing GraphPlot
has no effect. You must define a default value for this property, or define this property
using a Name,Value
pair during GraphPlot creation.
MATLAB executes the callback after creating the GraphPlot and setting
all of its properties.
If you specify this callback using a function handle, then MATLAB passes two arguments to the callback function when executing the callback:
The GraphPlot object — You can access properties of the
GraphPlot object from within the callback function. You also can access
the GraphPlot object through the CallbackObject
property of the root, which can be queried using the gcbo
function.
Event data — This argument is empty for this property. Replace it with the
tilde character (~
) in the function definition to indicate that this
argument is not used.
For more information on how to use function handles to define callback functions, see Callback Definition.
Example: @myCallback
Example: {@myCallback,arg3}
DeleteFcn
— Deletion callback''
(default) | function handle | cell array | character vectorDeletion callback, specified as one of these values:
Function handle
Cell array containing a function handle and additional arguments
Character vector that is a valid MATLAB command or function, which is evaluated in the base workspace (not recommended)
Use this property to execute code when you delete the GraphPlot. MATLAB executes the callback before destroying the GraphPlot so that the callback can access its property values.
If you specify this callback using a function handle, then MATLAB passes two arguments to the callback function when executing the callback:
The GraphPlot object — You can access properties of the
GraphPlot object from within the callback function. You also can access
the GraphPlot object through the CallbackObject
property of the root, which can be queried using the gcbo
function.
Event data — This argument is empty for this property. Replace it with the
tilde character (~
) in the function definition to indicate that this
argument is not used.
For more information on how to use function handles to define callback functions, see Callback Definition.
Example: @myCallback
Example: {@myCallback,arg3}
Interruptible
— Callback interruption'on'
(default) | on/off logical valueCallback interruption, specified as 'on'
or 'off'
, or as
numeric or logical 1
(true
) or
0
(false
). A value of 'on'
is equivalent to true
, and 'off'
is equivalent to
false
. 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 matlab.lang.OnOffSwitchState
.
This property determines if a running callback can be interrupted. There are two callback states to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
Whenever MATLAB invokes a callback, that callback attempts to interrupt the running
callback (if one exists). The Interruptible
property of the object
owning the running callback determines if interruption is allowed.
A value of 'on'
allows other callbacks to interrupt the
object's callbacks. The interruption occurs at the next point where
MATLAB processes the queue, such as when there is a drawnow
, figure
, uifigure
, getframe
, waitfor
, or pause
command.
If the running callback contains one of those commands, then MATLAB stops the execution of the callback at that point and executes the interrupting callback. MATLAB resumes executing the running callback when the interrupting callback completes.
If the running callback does not contain one of those commands, then MATLAB finishes executing the callback without interruption.
A value of 'off'
blocks all interruption attempts. The
BusyAction
property of the object owning the
interrupting callback determines if the interrupting callback is discarded
or put into a queue.
Callback interruption and execution behave differently in these situations:
If the interrupting callback is a DeleteFcn
, CloseRequestFcn
or SizeChangedFcn
callback, then the interruption occurs regardless of the Interruptible
property value.
If the running callback is currently executing the waitfor
function, then the interruption occurs regardless of the Interruptible
property value.
Timer
objects execute according to schedule regardless of the Interruptible
property value.
When an interruption occurs, MATLAB does not save the state of properties or the display. For example, the
object returned by the gca
or gcf
command might change when
another callback executes.
BusyAction
— Callback queuing'queue'
(default) | 'cancel'
Callback queuing specified as 'queue'
or 'cancel'
.
The BusyAction
property determines how MATLAB handles the execution of interrupting callbacks.
There are two callback states to consider:
The running callback is the currently executing callback.
The interrupting callback is a callback that tries to interrupt the running callback.
Whenever MATLAB invokes a callback, that callback attempts to interrupt a running callback. The
Interruptible
property of the object owning the running callback
determines if interruption is allowed. If interruption is not allowed, then the
BusyAction
property of the object owning the interrupting callback
determines if it is discarded or put in the queue.
If the ButtonDownFcn
callback of the GraphPlot tries
to interrupt a running callback that cannot be interrupted, then the
BusyAction
property determines if it is discarded or put in the queue.
Specify the BusyAction
property as one of these values:
'queue'
— Put the interrupting callback in a queue to be
processed after the running callback finishes execution. This is the default
behavior.
'cancel'
— Discard the interrupting callback.
PickableParts
— Ability to capture mouse clicks'visible'
(default) | 'none'
Ability to capture mouse clicks, specified as one of these values:
'visible'
— Can capture mouse clicks only when visible. The
Visible
property must be set to 'on'
. The
HitTest
property determines if the GraphPlot
responds to the click or if an ancestor does.
'none'
— Cannot capture mouse clicks. Clicking the GraphPlot passes the click to the object below it in the current view of the
figure window. The HitTest
property of the GraphPlot
has no effect.
HitTest
— Response to captured mouse clicks'on'
(default) | on/off logical valueResponse to captured mouse clicks, specified as 'on'
or
'off'
, or as numeric or logical 1
(true
) or 0
(false
). A
value of 'on'
is equivalent to true, and 'off'
is
equivalent to false
. 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 matlab.lang.OnOffSwitchState
.
'on'
— Trigger the
ButtonDownFcn
callback of the GraphPlot
object. If you have
defined the ContextMenu
property, then invoke the
context menu.
'off'
— Trigger the callbacks for the nearest
ancestor of the GraphPlot
object that has one of these:
HitTest
property set to
'on'
PickableParts
property set to a value that
enables the ancestor to capture mouse clicks
The PickableParts
property determines if
the GraphPlot
object can capture
mouse clicks. If it cannot, then the HitTest
property
has no effect.
BeingDeleted
— Deletion statusThis property is read-only.
Deletion status, returned as an on/off logical value of type matlab.lang.OnOffSwitchState
.
MATLAB sets the BeingDeleted
property to
'on'
when the DeleteFcn
callback begins
execution. The BeingDeleted
property remains set to
'on'
until the component object no longer exists.
Check the value of the BeingDeleted
property to verify that the object is not about to be deleted before querying or modifying it.
Parent
— Parent of GraphPlotParent of GraphPlot, specified as an axes, group, or transform object.
Children
— ChildrenGraphicsPlaceholder
array | DataTip
object arrayChildren, returned as an empty GraphicsPlaceholder
array or a
DataTip
object array. Use this property to view a list of data tips
that are plotted on the chart.
You cannot add or remove children using the Children
property. To add a
child to this list, set the Parent
property of the
DataTip
object to the chart object.
HandleVisibility
— Visibility of object handle'on'
(default) | 'off'
| 'callback'
Visibility of GraphPlot object handle in the
Children
property of the parent, specified as one of these values:
'on'
— The GraphPlot object handle is
always visible.
'off'
— The GraphPlot object handle is
invisible at all times. This option is useful for preventing unintended changes to the UI
by another function. Set the HandleVisibility
to
'off'
to temporarily hide the handle during the execution of that
function.
'callback'
— The GraphPlot object handle
is visible from within callbacks or functions invoked by callbacks, but not from within
functions invoked from the command line. This option blocks access to the GraphPlot at the command-line, but allows callback functions to access it.
If the GraphPlot object is not listed in the
Children
property of the parent, then functions that obtain object handles
by searching the object hierarchy or querying handle properties cannot return it. This
includes get
, findobj
, gca
, gcf
, gco
, newplot
, cla
, clf
, and close
.
Hidden object handles are still valid. Set the root
ShowHiddenHandles
property to 'on'
to list all object
handles regardless of their HandleVisibility
property setting.
Type
— Type of graphics object'graphplot'
This property is read-only.
Type of graphics object, returned as 'graphplot'
. Use this property to
find all objects of a given type within a plotting hierarchy, such as searching for the type
using findobj
.
Tag
— Tag to associate with GraphPlot''
(default) | character vectorTag to associate with the GraphPlot, specified as a character vector.
Tags provide a way to identify graphics objects. Use this property to find all objects with a
specific tag within a plotting hierarchy, for example, searching for the tag using findobj
.
Example: 'January Data'
Data Types: char
UserData
— Data to associate with GraphPlot[]
(default) | scalar, vector, or matrix | cell array | character array | table | structureData to associate with the GraphPlot object, specified as a scalar, vector, matrix, cell array, character array, table, or structure. MATLAB does not use this data.
To associate multiple sets of data or to attach a field name to the data, use the
getappdata
and setappdata
functions.
Example: 1:100
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| logical
| char
| struct
| table
| cell
UIContextMenu
property is not recommendedNot recommended starting in R2020a
Starting in R2020a, using the UIContextMenu
property to assign a
context menu to a graphics object or UI component is not recommended. Use the
ContextMenu
property instead. The property values are the same.
There are no plans to remove support for the UIContextMenu
property at
this time. However, the UIContextMenu
property no longer appears in the
list returned by calling the get
function on a graphics object or UI
component.