How can I multiple plot in one figure at Matlab?

有些话、适合烂在心里 提交于 2019-12-02 05:13:41

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.

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.

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)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!