Next: Multiple Plots on One Page, Previous: Three-Dimensional Plotting, Up: Plotting Basics
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.
Display a legend for 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. 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:
-1 To the top right of the plot 0 Don't move the legend box (default) 1 Upper right-hand corner 2 Upper left-hand corner 3 Lower left-hand corner 4 Lower right-hand corner Some specific functions are directely avaliable using func:
"show"
- Show legends from the plot
"hide"
off
- Hide legends from the plot
"boxon"
- Draw a box around legends
"boxoff"
- Withdraw the box around legends
"left"
- Text is to the left of the keys
"right"
- Text is to the right of the keys
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.
Specify x, y, and z axis labels for the current figure.
See also: plot, semilogx, semilogy, loglog, polar, mesh, contour, bar, stairs, ylabel, title.
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.See also: plot.