如何在Matlab的一个图形中绘制多个图? [英] How can I multiple plot in one figure at Matlab?

查看:1872
本文介绍了如何在Matlab的一个图形中绘制多个图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实现以下代码.

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?

推荐答案

用于同一图中而非同一轴的多个图.您必须使用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.

这篇关于如何在Matlab的一个图形中绘制多个图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆