Getting Started    

Setting Object Properties

All object properties have default values. However, you may find it useful to change the settings of some properties to customize your graph. There are two ways to set object properties:

Setting Properties from Plotting Commands

You can specify object property values as arguments to object creation functions as well as with plotting function, such as plot, mesh, and surf.

For example, plotting commands that create lines or surfaces enable you to specify property name/property value pairs as arguments. The command

plots the data in the variables x and y using lines having a LineWidth property set to 1.5 points (one point = 1/72 inch). You can set any line object property this way.

Setting Properties of Existing Objects

To modify the property values of existing objects, you can use the set command or, if plot editing mode is enabled, the Property Editor. The Property Editor provides a graphical user interface to many object properties. This section describes how to use the set command. See Using the Property Editor for more information.

Many plotting commands can return the handles of the objects created so you can modify the objects using the set command. For example, these statements plot a five-by-five matrix (creating five lines, one per column) and then set the Marker to a square and the MarkerFaceColor to green.

In this case, h is a vector containing five handles, one for each of the five lines in the plot. The set statement sets the Marker and MarkerFaceColor properties of all lines to the same values.

Setting Multiple Property Values

If you want to set the properties of each line to a different value, you can use cell arrays to store all the data and pass it to the set command. For example, create a plot and save the line handles.

Suppose you want to add different markers to each line and color the marker's face color to the same color as the line. You need to define two cell arrays - one containing the property names and the other containing the desired values of the properties.

The prop_name cell array contains two elements.

The prop_values cell array contains 10 values; five values for the Marker property and five values for the MarkerFaceColor property. Notice that prop_values is a two-dimensional cell array. The first dimension indicates which handle in h the values apply to and the second dimension indicates which property the value is assigned to.

The MarkerFaceColor is always assigned the value of the corresponding line's color (obtained by getting the line's Color property with the get command).

After defining the cell arrays, call set to specify the new property values.


  Graphics Objects Finding the Handles of Existing Objects