Graphics Previous page   Next Page

Disable Automatic Modes

Graphics objects have properties that control many aspects of their behavior and appearance. The axes object in particular has many mode properties that enables it to respond to changes in the data represented in a graph.

For example, when you plot data, the axes determines appropriate axis limits, tick-mark placement, and labeling. Any changes you make to the plotted data (adding another line graph, for example) causes the axes to recompute the axis limits and to determine what values to use for the tick marks.

Fixing Axis Limits

The process of recalculating axis limits and the locations of the tick marks along each axis contributes to the time it takes to create a graph. If you are plotting data into the same axes repeatedly, you can improve performance by manually setting some or all of the axis limits, which, in turn, disables axis scaling and tick picking.

For example, suppose you are plotting time series graphs in which you always view a 200 second time interval along the x-axis and your data ranges from -1 to 1. The following statement creates an axes with these limits and, in the process, sets the limit-picking mode to manual. Thereafter, MATLAB does not change the limits or recalculate tick mark locations (as long as you do not call a high-level plotting function like plot):

Set All Modes to Manual

To maximize the efficiency with which MATLAB can update your graphs, you should disable all automatic operation so that MATLAB does not need to spend time determining if it is even necessary to recalculate a property value. The following steps illustrate this technique:

  1. Create a figure and select the renderer you want to use. Line graphs should use painters to take advantage of its line thinning algorithm.
  1. Setting a property automatically sets its associated mode property to manual.

  1. Create an axes explicitly and set all properties (such as the axis limits) for which you can predetermine the appropriate value.
  2. Set all other mode property values to manual (see table below).
  3. If you are creating line graphs using the painters renderer, set the axes DrawMode property to fast.
  4. If you cannot determine the appropriate value for all mode properties, create your first graph and then use the set command to set mode properties to manual. See Changing Graph Data Rapidly for an example.

The following table lists the axes mode properties and provides an explanation of what the mode controls.

Mode Property
What It Controls
ALimMode
Transparency limits mode
CameraPositionMode
Positioning of the viewpoint
CameraTargetMode
Positioning of the camera target in the axes
CameraUpVectorMode
The direction of "up" in 2-D and 3-D views
CameraViewAngleMode
The size of the projected scene and stretch-to-fit behavior
CLimMode
Mapping of data values to colors
DataAspectRatioMode
Relative scaling of data units along x-, y-, and z-axes and stretch-to-fit behavior
DrawMode
Controls the way MATLAB renders graphics objects (use with line graphs)
PlotBoxAspectRatioMode
Relative scaling of plot box along x-, y-, and z-axes and stretch-to-fit behavior
TickDirMode
Direction of axis tick marks (in for 2-D, out for 3-D)
XLimMode
YLimMode
ZLimMode

Limits of the respective x, y, and z axes
XTickMode
YTickMode
ZTickMode

Tick mark spacing along the respective x-, y-, and z-axes
XTickLabelMode
YTickLabelMode
ZTickLabelMode

Tick mark labels along the respective x-, y-, and z-axes


Previous page  Optimizing Graphics Performance Changing Graph Data Rapidly Next page

© 1994-2005 The MathWorks, Inc.