A number of high-level plotting functions create plot objects. The properties of plot objects provide easy access to the important properties of the core graphics objects that the plot objects contain.

Plot object parents can be axes or group objects (hggroup or hgtransform). See Objects That Can Contain Other Objects for examples.

This table lists the plot objects and the graphing functions that use them. Click the object names to see a description of their properties.
Plot Objects

Object Purpose
areaseries Used to create area graphs.
barseries Used to create bar graphs.
contourgroup Used to create contour graphs.
errorbarseries Used to create errorbar graphs.
lineseries Used by line plotting functions (plot, plot3, etc.).
quivergroup Used to create quiver and quiver3 graphs.
scattergroup Used to create scatter and scatter3 graphs.
stairseries Used to create stairstep graphs (stairs).
stemseries Used to create stem and stem3 graphs.
surfaceplot Used by the surf and mesh group of functions.

Creating a Plot Object

For example, the following statements create a contour graph of the peaks function and then set the line style and width of the contour lines:

[x,y,z] = peaks;
[c,h] = contour(x,y,z);

The contour plot object lets you set the line width and style of the contour graph by setting two properties. Looking at the core objects contained in the contour plot object reveals a number of patch objects whose edges are used to implement the contour line, which you would otherwise need to set individually.

Identifying Plot Objects Programmatically

child_handles = get(h,'Children');
ans =

Plot objects all return hggroup as the value of the Type property. If you want to be able to identify plot objects programmatically but do not have access to the object’s handle, set a value for the object’s Tag property.

For example, the following statements create a bar graph with five barseries objects and assign a different value for the Tag property on each object:

h = bar(rand(5));

The cell array of property values must be transposed (‘) to have the proper shape. See the set function for more information on setting properties.

No User Default Values

You cannot define default values for plot objects.

Plot Objects and Backward Compatibility

[warning]The v6 option discussed in this section is now obsolete and will be removed in a future version of MATLAB.[/warning]

Plotting functions that create plot objects can introduce incompatibilities with code written before MATLAB Version 7.x. However, all plotting functions that return handles to plot objects support an optional argument (‘v6’) that forces the functions to use core objects, as was the case in MATLAB before Version 7.

  • See Plot Objects for a list of functions that create plot objects.
  • See Core Graphics Objects for a list of core graphics objects.

Saving Figures That Are Compatible with Previous Version of MATLAB

Create backward-compatible FIG-files by following these two steps:

  • Ensure that any plotting functions used to create the contents of the figure are called with the ‘v6’ argument, where applicable.
  • Use the ‘-v6’ option with the hgsave command.

For example:

h = figure;
t = 0:pi/20:2*pi;

You can set a general MATLAB preference to ensure that figures saved by selecting File>Save are backward compatible. To access MATLAB preferences, select Preferences from the Desktop File menu. Expand the General node and select MAT Files. Click Ensure backward compatibility (-v6). This setting affects all FIG-files and MAT-files that you create.