MATLAB第三讲 MATLAB图形绘制基本技术 .ppt
文本预览下载声明
* * * * * * * * * * * * * * * * 3.5 二维图形坐标轴的控制 subplot 命令用于在一幅图上创建多幅子图。Subplot(m, n, p) 或 subplot( mnp ) 将图形窗口分解为一个 m X n 的子图 (m X n 个坐标系统),其中 第 p 个坐标系统为当前坐标系统,plot 等命令在该坐标系统上绘曲线。 x=0:0.05*pi:0.5*pi; y=sin(x); subplot(211), plot(x, y); subplot(223), stem(x,y); subplot(224), rose(x,y) 3.5 二维图形坐标轴的控制 注意下例的复杂分割 subplot(211), plot(x, y); subplot(223), stem(x,y); subplot(224), rose(x,y) subplot(4,4,11), fill(x,y,r);subplot(4,4,12),feather(x,y); subplot(4,4,15),plot(x,y); subplot(4,4,16),stairs(x,y) 3.5 二维图形坐标轴的控制 新的分割必须不能破坏原有的分割,仔细观察下面两例子的区别 subplot(211),plot(x,y);subplot(312),plot(x,y) subplot(211),plot(x,y);subplot(313),plot(x,y) 3.5 二维图形坐标轴的控制 MATLAB还提供有一个更灵活的命令 axes 用于设定当前坐标系统位置,从而可以任意方式分割图形窗口。 axes( ‘position’, [left, bottom, width, height] ) 在当前图形窗口中指定位置创建坐标系统, [left, bottom, width, height] 取值在 (0,1)之间,且(0,0)表示图形窗口左下角坐标,而(1,1)表示右上角坐标。由若干 axes 函数调用得出的坐标系可以重叠且互不干扰。见下例 RECT = [left, bottom, width, height] specifies the location and size of the side of the axis box, relative to the lower-left corner of the Figure window, in normalized units where (0,0) is the lower-left corner and (1.0,1.0) is the upper-right. 3.5 二维图形坐标轴的控制 axes(pos,[0.2 0.2 0.6 0.4]); plot(x,y) axes(pos,[0.1 0.1 0.8 0.1]); plot(x,y) axes(pos,[0.5 0.5 0.4 0.4]); fill(x,y,g) axes(pos,[0.1 0.6 0.3 0.3]); stem(x,y) RECT = [left, bottom, width, height] 3.6 其他类型的二维图形绘制 MATLAB提供其他许多种类的二维图形绘制,前面已经用到了一些,可以用 help specgraph 命令查看MATLAB提供的命令,主要有以下一些。 bar 二维条形图 bar(x, y) comet 彗星状轨迹图 comet(x, y) compass 罗盘图 compass(x, y) errorbar 误差限图形 errorbar(x, y, l, u) feather 羽毛状图 feather(x, y) fill 二维填充函数 fill(x, y, c) hist 直方图 hist(x, y) pie 饼图 pie(x) quiver 磁力线图 quiver(x, y) stairs 阶梯图形 stairs(x, y) stem 火柴杆图 stem(x, y) 3.6 其他类型的二维图形绘制 下面几例说明这些图形的绘制 x=-2:0.1:2; y=sin(x); subplot(221); feather(x, y);subplot(222);stairs(x,y); subplot(223);stem(x,y); subplot(224);fill(x,y,r); 3.6 其他类型的二维图形绘制 下面几例说明这些图形的绘制 x=-2:0.1:2; y=sin(x); subplot(221);quiver(x,y); subplot(222);comet(x,y); subplot(223);q
显示全部