且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Matlab的一个图形中绘制多个图?

更新时间:2023-11-21 22:19:10

用于同一图中而非同一轴的多个图.您必须使用subplot(x,y,z).第一个参数"x"是您要生成的样例的数量(在您的情况下为3).第二个"y"只是调整样例的大小,可以使用1.第三个"z"是样例的位置,某个情节排在第一,第二还是第三.

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);

要区分所有三个图,可以在plot()中添加另一个参数,以便可以更改颜色.例如:

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'将情节的颜色设为红色,'b'使其为蓝色,'k'使其为黑色...等等.

'r' will make the color of the plot red, 'b' makes it blue, 'k' makes it black...so on.