Next: Multiple Plots on One Page, Previous: Three-Dimensional Plots, Up: High-Level Plotting [Contents][Index]
You can add titles, axis labels, legends, and arbitrary text to an existing plot. For example:
x = -10:0.1:10; plot (x, sin (x)); title ("sin(x) for x = -10:0.1:10"); xlabel ("x"); ylabel ("sin (x)"); text (pi, 0.7, "arbitrary text"); legend ("sin (x)");
The functions grid
and box
may also be used to add grid
and border lines to the plot. By default, the grid is off and the
border lines are on.
Create a title object for a plot.
The optional return value h is a graphics handle to the created object.
Display a legend for the axes with handle hax, or the current axes, using the specified strings as labels. Legend entries may be specified as individual character string arguments, a character array, or a cell array of character strings. If the handles, hobjs, are not specified then the legend’s strings will be associated with the axes’ descendants. Legend works on line graphs, bar graphs, etc. A plot must exist before legend is called.
The optional parameter pos specifies the location of the legend as follows:
pos | location of the legend | |
---|---|---|
north | center top | |
south | center bottom | |
east | right center | |
west | left center | |
northeast | right top (default) | |
northwest | left top | |
southeast | right bottom | |
southwest | left bottom | |
outside | can be appended to any location string |
The optional parameter orient determines if the key elements are placed vertically or horizontally. The allowed values are "vertical" or "horizontal" with the default being "vertical".
The following customizations are available using option:
Show legend on the plot
Hide legend on the plot
Toggles between "hide" and "show"
Show a box around legend
Hide the box around legend
Place text to the left of the keys
Place text to the right of the keys
Delete the legend object
Create a text object with text label at position x, y, z on the current axes. Property-value pairs following label may be used to specify the appearance of the text.
The optional return value h is a graphics handle to the created text object.
See Text Properties for the properties that you can set.
Specify x-, y-, or z-axis labels for the current axis. If h is specified then label the axis defined by h.
The optional return value h is a graphics handle to the created object.
Add labels to the contours of a contour plot. The contour plot is specified
by the contour matrix c and optionally the contourgroup object h
that are returned by contour
, contourf
and contour3
.
The contour labels are rotated and placed in the contour itself.
By default, all contours are labeled. However, the contours to label can be specified by the vector v. If the "manual" argument is given then the contours to label can be selected with the mouse.
Additional property/value pairs that are valid properties of text objects can be given and are passed to the underlying text objects. Additionally, the property "LabelSpacing" is available allowing the spacing between labels on a contour (in points) to be specified. The default is 144 points, or 2 inches.
The optional return value h is a vector of graphics handles to the text objects representing each label. The "userdata" property of the text objects contains the numerical value of the contour label.
An example of the use of clabel
is
[c, h] = contour (peaks (), -4 : 6); clabel (c, h, -4:2:6, "fontsize", 12);
Control the display of a border around the plot.
The argument may be either "on"
or "off"
. If it is
omitted, the current box state is toggled.
See also: grid.
Force the display of a grid on the plot.
The argument may be either "on"
, or "off"
.
If it is omitted, the current grid state is toggled.
If arg is "minor"
then the minor grid is toggled. When
using a minor grid a second argument arg2 is allowed, which can
be either "on"
or "off"
to explicitly set the state of
the minor grid.
If the first argument is an axis handle, hax, operate on the specified axis object.
See also: plot.
Add a colorbar to the current axes. Valid values for s are
Place the colorbar outside the plot to the right. This is the default.
Place the colorbar inside the plot to the right.
Place the colorbar outside the plot to the left.
Place the colorbar inside the plot to the left.
Place the colorbar above the plot.
Place the colorbar at the top of the plot.
Place the colorbar under the plot.
Place the colorbar at the bottom of the plot.
Remove any existing colorbar from the plot.
If the argument "peer" is given, then the following argument is treated as the axes handle on which to add the colorbar.
Next: Multiple Plots on One Page, Previous: Three-Dimensional Plots, Up: High-Level Plotting [Contents][Index]