正在加载图片...
作为一个使用图象句柄的例子,可以考虑前面提出的问题。它要用非标准颜色画一条线 在这里,线的颜色用RGB值1.50来指定,它是适中的橘黄色 -2*pi I >)y=sin(x); find the sine of x ))HI sin=plot(x, y) plot sine and save line handle HI 59.0002 >)set(H sin, Color, [1.50), Line Width, 3)% Change the color and width 现在加一个浅蓝色的 cosine曲线: >)Z=cos(x); find the cosine ofx >)hold on keep the sine curve plot(x, z); plot the cosine and save the hand >)set(HI cos, Color',[75.75 1 color it light blue hold off 也可以用较少的步骤来实现同样的功能 >HI lines-plot(x, y, x, z); plot both curves and save both handles >)set(HI line( 1), Color, [1.501, Linewidth, 3) >)set(HI line( 2), Color, [75. ID) 如何加上一个标题并且使字体比正常大一些呢 >)title( Handle Graphics Example) add a title >Ht text=get(gca, Title)% get a handle to the title >)set(Ht text, FontSize, 16) customize the font size 最后一个例子说明了关于坐标轴对象令人感兴趣的性质。每一个对象都含有 Parent属性 和' Children’属性,该属性包含属于派生对象的句柄。画在一组坐标轴上的线,具有当作 Parent'属性值的坐标轴对象的句柄,而‘ Children‘属性值是一个空距阵。同时,这个坐标轴 对象具有当作‘ Parent‘属性值的图形句柄,而‘ Children‘属性值是线条对象的句柄。标题字 符串和坐标轴的标志不包含在坐标轴的‘ Children‘属性值里,而是保存在‘ Title‘、‘ Xlabel Ylabel‘和‘ Zlabel‘的属性内。创建坐标轴对象时,这些文本对象就建立。 title命令设 置当前坐标轴内标题文本对象的 String属性。最终,标准 MATLAB的函数tte, xlabel, ylabel 和 zlabel不返回句柄,而只接受属性和数值参量。例如下面的命令给当前图加一个24点的绿色 标题 >)title( This is a title., Fontsize, 24, Color', green)作为一个使用图象句柄的例子,可以考虑前面提出的问题。它要用非标准颜色画一条线。 在这里,线的颜色用 RGB 值[1 .5 0]来指定,它是适中的橘黄色。 » x=-2*pi:pi/40:2*pi; % create data » y=sin(x); % find the sine of x » Hl_sin=plot(x,y) % plot sine and save line handle Hl_sin= 59.0002 » set(Hl_sin, ‘Color’ ,[1 .5 0], ‘LineWidth’ ,3) % Change the color and width 现在加一个浅蓝色的 cosine 曲线: » z=cos(x); % find the cosine of x » hold on % keep the sine curve » Hl_cos=plot(x,z); % plot the cosine and save the handle » set(Hl_cos, ‘Color’ ,[.75 .75 1]) % color it light blue » hold off 也可以用较少的步骤来实现同样的功能: » Hl_lines=plot(x,y,x,z); % plot both curves and save both handles » set(Hl_line(1), ‘Color’ ,[1 .5 0], ‘LineWidth’ ,3) » set(Hl_line(2), ‘Color’ ,[.75 .75 1]) 如何加上一个标题并且使字体比正常大一些呢? » title( ‘Handle Graphics Example’ ) % add a title » Ht_text=get(gca, ‘Title’ ) % get a handle to the title » set(Ht_text, ‘FontSize’ ,16) % customize the font size 最后一个例子说明了关于坐标轴对象令人感兴趣的性质。每一个对象都含有 ‘Parent’ 属性 和 ‘Children’ 属性,该属性包含属于派生对象的句柄。画在一组坐标轴上的线,具有当作 ‘Parent’ 属性值的坐标轴对象的句柄,而 ‘ Children ‘ 属性值是一个空距阵。同时,这个坐标轴 对象具有当作 ‘ Parent ‘ 属性值的图形句柄,而 ‘ Children ‘ 属性值是线条对象的句柄。标题字 符串和坐标轴的标志不包含在坐标轴的 ‘ Children ‘ 属性值里,而是保存在 ‘ Title ‘ 、 ‘ Xlabel ‘ 、 ‘ Ylabel ‘ 和 ‘ Zlabel ‘ 的属性内。创建坐标轴对象时,这些文本对象就建立。title 命令设 置当前坐标轴内标题文本对象的 ‘String’ 属性。最终,标准 MATLAB 的函数 title,xlabel,ylabel 和 zlabel 不返回句柄,而只接受属性和数值参量。例如下面的命令给当前图加一个 24 点的绿色 标题: » title( ‘This is a title.’ , ‘Fontsize’ ,24, ‘Color’ , ‘green’ )
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有