Multiple Plots on the same axes

As seen in the previous example, we can add multiple plots on the same axes using the hold trigger. The syntax of the same is:

hold on

plot1

plot2

.

.plot N

hold off

This will plot all the plots that are written in between the hold-on and hold-off commands.

Example 5

The plot of linear, quadratic, and cubic polynomials of y=x. 

Matlab




% % MATLAB code for Multiple Plots
% on the Same axes
x = linspace(-3,3,10000);
  
hold on
plot(x,.1*x)
plot(x,.1*x.^2)
plot(x,.1*x.^3)
hold off


Output:

 

Axes Appearance and Behavior in MATLAB

MATLAB offers many types of axes such as polar axes, cartesian axes, etc. The default appearances of these axes are dynamically determined by MATLAB on case-by-case requirements. However, MATLAB does provide its users the option to alter the behavior of these axes, by using some built-in functions. In this article, we shall how we can use these functions to alter the appearance of cartesian axes; the same methods could be applied to polar axes and other available axis types.

Similar Reads

Axes Properties:

Axes Ticks Grids and gridlines Axes labels Legends Multiple Plots on the same axes Axes Position and aspect ratio Axes limits...

Axes Ticks:

We can change the values of points where the x-ticks are marked as well as their labels....

Grid and Gridlines:

...

Axes Label:

In MATLAB we get the option to display gridlines and the option to have minor gridlines as well. In the case of minor gridlines, the gridlines on tick points are normal whereas the lines in between major ticks are fainter. Syntax of the same is:...

Legends:

...

Multiple Plots on the same axes:

You can simply change the x, y, and/or z axis’s label by using the following commands...

Changing Axes Position and Aspect Ratio:

...

Axes Limits:

We can add legends to a set of axes with the help of the legend() function....