Hi I\'m trying to implement as following code.
plot(bins,r);
plot(bins,g);
plot(bins,b);
But I want to plot in one figure. Is there any way?
You need to use hold on
hold on retains plots in the current axes so that new plots added to the axes do not delete existing plots. New plots use the next colors and line styles based on the ColorOrder and LineStyleOrder properties of the axes. MATLAB® adjusts axes limits, tick marks, and tick labels to display the full range of data.
hold on
plot(bins,r)
plot(bins,g)
plot(bins,b)
Yes, you can plot everything in one go:
plot(bins,r,bins,g,bins,b)
or use hold on
after the first call to plot.
For multiple plots in the same figure and not the same axis. You have to use subplot(x,y,z). The first argument 'x' is the number of plot you want to produce, in your case 3. Second 'y' just adjusts the size of the plots, you can use 1. The third 'z' is the position of the plot, whether a certain plot comes first, second or third.
subplot(3,1,1)
plot(bins,r);
subplot(3,1,2)
plot(bins,g);
subplot(3,1,3)
plot(bins,g);
To distinguish between all three plot you can add another argument to plot() so that you can change colors. For example:
plot(bins,r,'r')
'r' will make the color of the plot red, 'b' makes it blue, 'k' makes it black...so on.