This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

ConfusionMatrixChart Properties

Confusion matrix chart appearance and behavior

ConfusionMatrixChart properties control the appearance and behavior of a ConfusionMatrixChart object. By changing property values, you can modify certain aspects of the confusion matrix chart. For example, you can add a title:

cm = confusionchart([1 3 5; 2 4 6; 11 7 3]);
cm.Title = 'My Confusion Matrix Title';

Labels

expand all

Title of the confusion matrix chart, specified as a character vector or string scalar.

Example: cm = confusionchart(__,'Title','My Title Text')

Example: cm.Title = 'My Title Text'

Label for the x-axis, specified as a string scalar or character vector.

Example: cm = confusionchart(__,'XLabel','My Label')

Example: cm.XLabel = 'My Label'

Label for the x-axis, specified as a string scalar or character vector.

Example: cm = confusionchart(__,'YLabel','My Label')

Example: cm.YLabel = 'My Label'

This property is read-only.

Class labels of the confusion matrix chart, stored as a categorical vector, numeric vector, string vector, character array, cell array of character vectors, or logical vector.

Row and Column Summaries

expand all

Column summary of the confusion matrix chart, specified as one of the following:

OptionDescription
'off'Do not display a column summary.
'absolute'Display the total number of correctly and incorrectly classified observations for each predicted class.
'column-normalized'Display the number of correctly and incorrectly classified observations for each predicted class as percentages of the number of observations of the corresponding predicted class. The percentages of correctly classified observations can be thought of as class-wise precisions (or positive predictive values).
'total-normalized'Display the number of correctly and incorrectly classified observations for each predicted class as percentages of the total number of observations.

Example: cm = confusionchart(__,'ColumnSummary','column-normalized')

Example: cm.ColumnSummary = 'column-normalized'

Row summary of the confusion matrix chart, specified as one of the following:

OptionDescription
'off'Do not display a row summary.
'absolute'Display the total number of correctly and incorrectly classified observations for each true class.
'row-normalized'Display the number of correctly and incorrectly classified observations for each true class as percentages of the number of observations of the corresponding true class. The percentages of correctly classified observations can be thought of as class-wise recalls (or true positive rates).
'total-normalized'Display the number of correctly and incorrectly classified observations for each true class as percentages of the total number of observations.

Example: cm = confusionchart(__,'RowSummary','row-normalized')

Example: cm.RowSummary = 'row-normalized'

Data

expand all

This property is read-only.

Values of the confusion matrix, stored as a numeric matrix. This property equals the values of the confusion matrix normalized using the method of the Normalization property. The software recalculates the normalized values of the confusion matrix each time you modify the Normalization property.

Normalization of cell values, specified as one of the following:

OptionDescription
'absolute'Display the total number of observations in each cell.
'column-normalized'Normalize each cell value by the number of observations that has the same predicted class.
'row-normalized'Normalize each cell value by the number of observations that has the same true class.
'total-normalized'Normalize each cell value by the total number of observations.

Modifying the normalization of cell values also affects the colours of the cells.

Example: cm = confusionchart(__,'Normalization','total-normalized')

Example: cm.Normalization = 'total-normalized'

Color and Styling

expand all

State of grid visibility, specified as one of the following:

  • 'on' — Display grid lines between the chart cells.

  • 'off' — Do not display grid lines between the chart cells.

Example: cm = confusionchart(__,'GridVisible','off')

Example: cm.GridVisible = 'off'

Color for diagonal cells, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. The color of each diagonal cell is proportional to the cell value and the DiagonalColor property, normalized to the largest cell value of the confusion matrix chart. Cells with positive values are colored with a minimum amount of color, proportional to the DiagonalColor property.

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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
'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 TripletHexadecimal Color CodeAppearance
[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'

The software chooses an appropriate text color for cell labels automatically, depending on the color of the chart cells.

Example: cm = confusionchart(__,'DiagonalColor','blue')

Example: cm.DiagonalColor = 'blue'

Color for off-diagonal cells, specified as an RGB triplet, a hexadecimal color code, a color name, or a short name. The color of each diagonal cell is proportional to the cell value and the OffDiagonalColor property, normalized to the largest cell value of the confusion matrix chart. Cells with positive values are colored with a minimum amount of color, proportional to the OffDiagonalColor property.

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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
'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 TripletHexadecimal Color CodeAppearance
[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'

The software chooses an appropriate text color for cell labels automatically, depending on the color of the chart cells.

Example: cm = confusionchart(__,'OffDiagonalColor','blue')

Example: cm.OffDiagonalColor = 'blue'

Text color for title, axis labels, and class labels, specified as a color name, an RGB triplet, a hexadecimal color code, a color name, or a short name.

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 NameShort NameRGB TripletHexadecimal Color CodeAppearance
'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 TripletHexadecimal Color CodeAppearance
[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'

The software chooses an appropriate text color for cell labels automatically, depending on the color of the chart cells.

Example: cm = confusionchart(__,'FontColor','blue')

Example: cm.FontColor = 'blue'

Font

expand all

Font name, specified as a system supported font name. The default font depends on the specific operating system and locale.

Example: cm = confusionchart(__,'FontName','Cambria')

Example: cm.FontName = 'Cambria'

Font size used for the title, axis labels, class labels, and cell labels, specified as a positive scalar. The default font depends on the specific operating system and locale.

The title and axis labels use a slightly larger font size (scaled up by 10%). If there is not enough room to display the cell labels within the cells, then the cell labels use a smaller font size. If the cell labels become too small, then they are hidden.

Example: cm = confusionchart(__,'FontSize',12)

Example: cm.FontSize = 12

Position

expand all

Position property to hold constant during resize operations, specified as 'outerposition' or 'innerposition'. The default value of 'outerposition' means that the OuterPosition property remains constant. The InnerPosition property value can change when the parent container changes size, the data changes, or the labels change.

Example: cm = confusionchart(__,'ActivePositionProperty','innerposition')

Example: cm.ActivePositionProperty = 'innerposition'

Outer size and position within the parent container (a figure, panel, or tab), specified as a four-element vector of the form [left bottom width height]. The outer position includes the title, axis labels, and class labels.

  • The left and bottom elements define the distance from the lower left corner of the container to the lower left corner of the chart.

  • The width and height elements are the chart dimensions, which include the chart cells, plus a margin for the surrounding text.

The default value of [0 0 1 1] is the whole interior of the container.

By default, the values are normalized to the container. To change the units, set the Units property.

Example: cm = confusionchart(__,'OuterPosition',[0.1 0.1 0.8 0.8])

Example: cm.OuterPosition = [0.1 0.1 0.8 0.8]

Inner size and position of the chart within the parent container (a figure, panel, or tab) returned as a four-element vector of the form [left bottom width height]. The inner position does not include the title, axis labels, or class labels.

  • The left and bottom elements define the distance from the lower left corner of the container to the lower left corner of the chart.

  • The width and height elements are the chart dimensions, which include only the chart cells.

Example: cm = confusionchart(__,'InnerPosition',[0.1 0.1 0.8 0.8])

Example: cm.InnerPosition = [0.1 0.1 0.8 0.8]

Inner size and position of the chart within the parent container (a figure, panel, or tab) returned as a four-element vector of the form [left bottom width height]. This property is equivalent to the InnerPosition property.

Position units, specified as one of these values:

UnitsDescription
'normalized'Normalized with respect to the container, which is typically the figure or a panel. The lower left corner of the container maps to (0,0), and the upper right corner maps to (1,1).
'inches'Inches.
'centimeters'Centimeters.
'characters'

Based on the default uicontrol font of the graphics root object:

  • Character width = width of letter x.

  • Character height = distance between the baselines of two lines of text.

'points'Typography points. One point equals 1/72 inch.
'pixels'

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.

When specifying the units as a name-value pair during object creation, you must set the Units property before specifying the properties that you want to use these units for, such as OuterPosition.

State of visibility, specified as one of these values:

  • 'on' — Display the chart.

  • 'off' — Hide the chart without deleting it. You still can access the properties of an invisible chart.

Parent/Child

expand all

Parent container, specified as a figure, panel, or tab object.

Visibility of the chart object handle in the Children property of the parent, specified as one of these values:

  • 'on' — Object handle is always visible.

  • 'off' — Object handle is invisible at all times. This option is useful for preventing unintended changes to the UI by another function. To temporarily hide the handle during the execution of that function, set the HandleVisibility to 'off'.

  • 'callback' — 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 object at the command line, but allows callback functions to access it.

If the 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.

Introduced in R2018b