Graphics |
Adding Plots to an Existing Graph
You can add plots to an existing graph using the hold
command. When you set hold
to on
, MATLAB does not remove the existing graph; it adds the new data to the current graph, rescaling if the new data falls outside the range of the previous axis limits.
For example, these statements first create a semilogarithmic plot, then add a linear plot.
semilogx(1:100,'+') hold all% hold plot and cycle line colors
plot(1:3:300,1:100,'--') hold off grid on% Turn on grid lines for this plot
While MATLAB resets the x-axis limits to accommodate the new data, it does not change the scaling from logarithmic to linear.
The graph shows a semilogarithmic scale on the x-axis and a linear scale on the y-axis. The semilogx plot is drawn with blue plus signs and the linear plot is drawn with green dashed lines.
Specifying the Color and Size of Lines | Plotting Only the Data Points |
© 1994-2005 The MathWorks, Inc.