ScatterHistogramChart Properties

Control scatter histogram chart appearance and behavior

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

s = scatterhistogram(rand(10,1),rand(10,1));
s.Title = 'My Title';

Labels

expand all

Chart title, specified as a character vector, string array, cell array of character vectors, or categorical array. The default chart has no title.

To create a multiline title, specify a string array or cell array of character vectors. Each element in the array corresponds to a line of text.

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

Example: s = scatterhistogram(__,'Title','My Title Text')

Example: s.Title = 'My Title Text'

Example: s.Title = {'My','Title'}

Label for the x-axis, specified as a character vector, string array, cell array of character vectors, or categorical array. Use '' for no label.

To create a multiline label, specify a string array or cell array of character vectors. Each element in the array corresponds to a line of text.

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

Example: s = scatterhistogram(__,'XLabel','My Label')

Example: s.XLabel = 'My Label'

Example: s.XLabel = {'My','Label'}

Label for the y-axis, specified as a character vector, string array, cell array of character vectors, or categorical array. Use '' for no label.

To create a multiline label, specify a string array or cell array of character vectors. Each element in the array corresponds to a line of text.

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

Example: s = scatterhistogram(__,'YLabel','My Label')

Example: s.YLabel = 'My Label'

Example: s.YLabel = {'My','Label'}

Legend title, specified as a character vector, string array, cell array of character vectors, or categorical array. Use '' for no title.

To create a multiline title, specify a string array or cell array of character vectors. Each element in the array corresponds to a line of text.

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

Example: s = scatterhistogram(__,'LegendTitle','My Title Text')

Example: s.LegendTitle = 'My Title Text'

Example: s.LegendTitle = {'My','Title'}

Histograms

expand all

Number of histogram bins, specified as a positive integer scalar, 2-by-1 positive integer vector, or 2-by-n positive integer matrix, where n is the number of groups in GroupData.

Specified ValueDescription
scalarThe value is the number of bins for the x and y histograms.
2-by-1 vectorThe first value is the number of bins for the x data, and the second value is the number of bins for the y data.
2-by-n matrixThe (1,j) value is the number of bins for the histogram of the x data that is in the jth group. Similarly, the (2,j) value is the number of bins for the histogram of the y data that is in the jth group.

scatterhistogram uses the 'BinMethod','auto' name-value pair argument of histogram to determine the default NumBins and BinWidths values.

You cannot change NumBins for categorical data.

Example: s = scatterhistogram(__,'NumBins',20)

Example: s.NumBins = [10; 15]

Histogram bin widths, specified as a positive scalar, 2-by-1 positive vector, or 2-by-n positive matrix, where n is the number of groups in GroupData.

Specified ValueDescription
scalarThe value is the bin width for the x and y histograms.
2-by-1 vectorThe first value is the bin width for the x data, and the second value is the bin width for the y data.
2-by-n matrixThe (1,j) value is the bin width for the histogram of the x data that is in the jth group. Similarly, the (2,j) value is the bin width for the histogram of the y data that is in the jth group.

scatterhistogram uses the 'BinMethod','auto' name-value pair argument of histogram to determine the default NumBins and BinWidths values. The BinWidths values for categorical data are always 0.

If you set BinWidths, then scatterhistogram ignores the NumBins value.

Example: s = scatterhistogram(__,'BinWidths',0.5)

Example: s.BinWidths = [1.5; 2]

Direction of the x data histograms, specified as 'up' or 'down'. If the XHistogramDirection value is 'up', then the x data histograms have bars directed upwards. If the XHistogramDirection value is 'down', then the x data histograms have bars directed downwards.

Example: s = scatterhistogram(__,'XHistogramDirection','down')

Example: s.XHistogramDirection = 'down'

Direction of the y data histograms, specified as 'right' or 'left'. If the YHistogramDirection value is 'right', then the y data histograms have bars directed rightwards. If the YHistogramDirection value is 'left', then the y data histograms have bars directed leftwards.

Example: s = scatterhistogram(__,'YHistogramDirection','left')

Example: s.YHistogramDirection = 'left'

Histogram display style, specified as one of these options.

Display StyleDescription
'stairs'Display a stairstep plot that shows the outline of the histogram without filling the bars.
'bar'Display a histogram bar plot.
'smooth'Display a smooth plot generated through kernel density estimates. This option requires a Statistics and Machine Learning Toolbox™ license.

scatterhistogram uses the 'pdf' type of normalization to generate the histograms. For more information, see the 'Normalization' name-value pair argument of histogram.

Example: s = scatterhistogram(__,'HistogramDisplayStyle','smooth')

Example: s.HistogramDisplayStyle = 'bar'

Histogram line style, specified in one of these forms:

  • Character vector designating one line style

  • String array or cell array of character vectors designating one or more line styles

Choose among these line style options.

Line StyleDescriptionResulting Line
'-'Solid line

'--'Dashed line

':'Dotted line

'-.'Dash-dotted line

'none'No lineNo line

When the total number of groups exceeds the number of specified line styles, scatterhistogram cycles through the specified line styles.

Example: s = scatterhistogram(__,'LineStyle',':')

Example: s.LineStyle = {':','-','-.'}

Histogram line width, specified as a positive scalar or positive vector in points. By default, scatterhistogram assigns a line width of 0.5 to each histogram plot line.

When the total number of groups exceeds the number of specified line widths, scatterhistogram cycles through the specified line widths.

Example: s = scatterhistogram(__,'LineWidth',0.75)

Example: s.LineWidth = [0.5 0.75 0.5]

Color and Font

expand all

Group color, specified in one of these forms:

  • Character vector designating a color name.

  • String array or cell array of character vectors designating one or more color names.

  • Three-column matrix of RGB values in the range [0,1]. The three columns represent the R value, G value, and B value, respectively.

Choose among these predefined colors and their equivalent RGB triplets.

OptionDescriptionEquivalent RGB Triplet
'red' or 'r'Red[1 0 0]
'green' or 'g'Green[0 1 0]
'blue' or 'b'Blue[0 0 1]
'yellow' or 'y'Yellow[1 1 0]
'magenta' or 'm'Magenta[1 0 1]
'cyan' or 'c'Cyan[0 1 1]
'white' or 'w'White[1 1 1]
'black' or 'k'Black[0 0 0]

By default, scatterhistogram assigns a maximum of seven unique group colors. When the total number of groups exceeds the number of specified colors, scatterhistogram cycles through the specified colors.

Example: s = scatterhistogram(__,'Color',{'blue','green',red'})

Example: s.Color = [0 0 1; 0 0.5 0.5; 0.5 0.5 0.5]

Font name, specified as a system-supported font name. The same font is used for the title, axis labels, legend title, and group names. The default font depends on the specific operating system and locale.

Example: s = scatterhistogram(__,'FontName','Cambria')

Example: s.FontName = 'Cambria'

Font size, specified as a scalar value. FontSize is the same for the title, axis labels, legend title, and group names. The default font size depends on the specific operating system and locale.

As you adjust the size of plot elements, the software automatically updates the font size. However, changing the FontSize property disables this automatic resizing.

Example: s = scatterhistogram(__,'FontSize',12)

Example: s.FontSize = 12

Markers

expand all

Marker symbol for each scatter plot group, specified in one of these forms:

  • Character vector designating a marker style

  • String array or cell array of character vectors designating one or more marker styles

Choose among these marker options.

ValueDescription
'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

By default, scatterhistogram assigns the marker symbol 'o' to each group in the scatter plot. When the total number of groups exceeds the number of specified symbols, scatterhistogram cycles through the specified symbols.

Example: s = scatterhistogram(__,'MarkerStyle','x')

Example: s.MarkerStyle = {'x','o'}

Marker size for each scatter plot group, specified as a nonnegative scalar or nonnegative vector, with values measured in points. By default, scatterhistogram assigns 36 as the marker size for each group in the scatter plot. When the total number of groups exceeds the number of specified values, scatterhistogram cycles through the specified values.

Example: s = scatterhistogram(__,'MarkerSize',30)

Example: s.MarkerSize = 40

State of marker face fill, specified as 'on' or 'off'. If MarkerFilled is set to 'on', then scatterhistogram fills the interior of the markers in the scatter plot. If MarkerFilled is set to 'off', then scatterhistogram leaves the interior of the scatter plot markers empty.

Example: s = scatterhistogram(__,'MarkerFilled','off')

Example: s.MarkerFilled = 'off'

Marker transparency for each scatter plot group, specified as a numeric scalar or numeric vector with values between 0 and 1. Values closer to 0 specify more transparent markers, and values closer to 1 specify more opaque markers. By default, scatterhistogram assigns a MarkerAlpha value of 1 to all markers in the scatter plot.

Example: s = scatterhistogram(__,'MarkerAlpha',0.75)

Example: s.MarkerAlpha = [0.2 0.7 0.4]

Layout

expand all

Location of the scatter plot, specified as one of these options.

LocationDescription
'SouthWest'Plot the histograms above and to the right of the scatter plot.
'SouthEast'Plot the histograms above and to the left of the scatter plot.
'NorthEast'Plot the histograms below and to the left of the scatter plot.
'NorthWest'Plot the histograms below and to the right of the scatter plot.

Example: s = scatterhistogram(__,'ScatterPlotLocation','NorthEast')

Example: s.ScatterPlotLocation = 'SouthEast'

Ratio of the scatter plot length to the overall chart length, specified as a numeric scalar between 0 and 1. The ScatterPlotProportion value applies to both x and y axes.

Example: s = scatterhistogram(__,'ScatterPlotProportion',0.7)

Example: s.ScatterPlotProportion = 0.6

State of legend visibility, specified as 'on' or 'off'. Set LegendVisible to 'on' to display the legend or 'off' to hide the legend.

If GroupData is empty ([]) or contains a single group, then scatterhistogram does not display a legend. Otherwise, scatterhistogram displays a legend by default, unless the legend overlaps the scatter plot or marginal histograms.

In the legend, scatterhistogram displays the group names in order of their first appearance in GroupData.

Example: s = scatterhistogram(__,'LegendVisible','on')

Example: s.LegendVisible = 'off'

Position

expand all

Position property to hold constant when adding, removing, or changing decorations, specified as one of the following values:

  • 'outerposition' — The OuterPosition property remains constant when you add, remove, or change decorations such as a title or an axis label. If any positional adjustments are needed, MATLAB adjusts the InnerPosition property.

  • 'innerposition' — The InnerPosition property remains constant when you add, remove, or change decorations such as a title or an axis label. If any positional adjustments are needed, MATLAB adjusts the OuterPosition property.

This figure shows the innerposition and outerposition definitions for ScatterHistogramChart.

Example: s.ActivePositionProperty = 'outerposition'

Note

Setting this property has no effect when the parent container is a TiledChartLayout.

Inner size and position of the chart within the parent container (typically a figure, panel, or tab), specified as a four-element numeric vector of the form [left bottom width height]. The inner position includes only the scatter plot.

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

  • The width and height elements are the dimensions of the scatter plot.

For an illustration, see ActivePositionProperty.

Note

Setting this property has no effect when the parent container is a TiledChartLayout.

Outer size and position of the full scatter histogram chart within the parent container (typically a figure, panel, or tab), specified as a four-element numeric vector of the form [left bottom width height]. The default value of [0 0 1 1] includes the whole interior of the container.

For an illustration, see ActivePositionProperty.

Note

Setting this property has no effect when the parent container is a TiledChartLayout.

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

Note

Setting this property has no effect when the parent container is a TiledChartLayout.

Position units, specified as one of these values.

UnitsDescription
'normalized' (default)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/96 inch.

  • On Macintosh systems, a pixel is 1/72 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, such as OuterPosition.

Layout options, specified as a TiledChartLayoutOptions object. This property specifies options when the chart is a child of a tiled chart layout. Use this property to position the chart within the layout by setting the Tile and TileSpan properties on the TiledChartLayoutOptions object.

For example, this code places chart c in the third tile of a tiled chart layout.

c.Layout.Tile = 3;

To make the chart span multiple tiles, specify the TileSpan property as a two-element vector. For example, this chart spans 2 rows and 3 columns of tiles.

c.Layout.TileSpan = [2 3];

If the chart is not a child of a tiled chart layout (for example, if it is a child of a figure or panel), then this property is empty and has no effect.

State of object visibility, specified as one of these values:

  • 'on' — Display the ScatterHistogramChart object.

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

Data and Limits

expand all

Source table, specified as a table.

You can create a table from workspace variables using the table function, or you can import data as a table using the readtable function.

Note

The property is ignored and read-only when you use arrays instead of tabular data.

Table variable for x-axis, specified in one of these forms:

  • Character vector or string scalar indicating one of the variable names

  • Numeric scalar indicating the table variable index

  • Logical vector containing one true element

The values associated with your table variable must be of a numeric type or categorical.

If you set the XVariable property value, then the XData property automatically updates to appropriate values.

Note

The property is ignored and read-only when you use arrays instead of tabular data.

Example: s.XVariable = 'Acceleration' specifies the variable named 'Acceleration'.

Table variable for y-axis, specified in one of these forms:

  • Character vector or string scalar indicating one of the variable names

  • Numeric scalar indicating the table variable index

  • Logical vector containing one true element

The values associated with your table variable must be of a numeric type or categorical.

If you set the YVariable property value, then the YData property automatically updates to appropriate values.

Note

The property is ignored and read-only when you use arrays instead of tabular data.

Example: s.YVariable = 'Horsepower' specifies the variable named 'Horsepower'.

Table variable for grouping data, specified in one of these forms:

  • Character vector or string scalar indicating one of the variable names

  • Numeric scalar indicating the table variable index

  • Logical vector containing one true element

The values associated with your table variable must form a numeric vector, logical vector, categorical array, string array, or cell array of character vectors.

GroupVariable splits the data in XVariable and YVariable into unique groups. Each group has a default color and an independent histogram in each axis. In the legend, scatterhistogram displays the group names in order of their first appearance in GroupData.

When you specify the group variable, MATLAB updates the GroupData property values.

Note

This property is ignored and read-only when you use arrays instead of tabular data.

Example: s.GroupVariable = 'Origin'

Values appearing along the x-axis, specified as a numeric vector or categorical array.

If you are using tabular data, you cannot set this property. The XData values automatically populate based on the table variable you select with the XVariable property.

Example: s.XData = [0.5 4.3 2.4 5.6 3.4]

Values appearing along the y-axis, specified as a numeric vector or categorical array.

If you are using tabular data, you cannot set this property. The YData values automatically populate based on the table variable you select with the YVariable property.

Example: s.YData = [0.5 4.3 2.4 5.6 3.4]

Group values for the scatter plot and the corresponding marginal histograms, specified as a numeric vector, logical vector, categorical array, string array, or cell array of character vectors.

GroupData splits the data in XData and YData into unique groups. Each group has a default color and an independent histogram in each axis. In the legend, scatterhistogram displays the group names in order of their first appearance in GroupData.

If you are using tabular data, you cannot set this property. The GroupData values automatically populate based on the table variable you select with the GroupVariable property.

Example: s.GroupData = [1 2 1 3 2 1 3]

Example: s.GroupData = {'blue','green','green','blue','green'}

x-axis limits, specified as a two-element numeric vector or two-element categorical vector. By default, the values are derived from the XData values.

Example: s.XLimits = categorical({'blue','green'})

Example: s.XLimits = [10 50]

y-axis limits, specified as a two-element numeric vector or two-element categorical vector. By default, the values are derived from the YData values.

Example: s.YLimits = categorical({'blue','green'})

Example: s.YLimits = [10 50]

Parent/Child

expand all

Parent container, specified as a Figure, Panel, Tab, or TiledChartLayout object.

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

  • 'on' — Object handle is always visible.

  • 'off' — Object handle is always invisible. 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 the object. These functions include 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