正文

MATLAB的图视化功能(二)2007-06-30 14:25:00

【评论】 【打印】 【字体: 】 本文链接:http://blog.pfan.cn/emath/27228.html

分享到:

(3)    图视效果强化

例:加入格栅;坐标轴标志;文本说明等

clf;   hold off

t=linspace(0,pi*3,30);

x=sin(t);

hold on

y=cos(t);

plot(t,x,'r-',t,y,'g-')

 

grid    % 加入格栅

xlabel('x')

ylabel('y')

title('正弦与余弦曲线')

text(1,0,'正弦')    %text(x,y,'正弦')

text(3,0,'余弦')

legend('sin(x)','cos(x)',3)

%LEGEND('string',Pos) places the legend in the specified,

%        0 = Automatic "best" placement (least conflict with data)

%        1 = Upper right-hand corner (default)

%        2 = Upper left-hand corner

%        3 = Lower left-hand corner

%        4 = Lower right-hand corner

%       -1 = To the right of the plot

%按鼠表 left mouse button  legend到指定的位置   

 

 

 

 

(1) 子图

clf;   hold off

t=linspace(0,pi*3,30);

x=sin(exp(t));

subplot (2,2,2)   %(n,m,p(0<p<m*n)

plot (t,x,'r-')

y=exp(sin(t));

subplot (2,2,3)

plot (t,y,'g-')  

 

 

 

(2) 特殊二维图形

bar

直方图

loglog

双对数坐标曲线

compass

原点出发的复数向量图(罗盘图)

pcolor

伪彩图

contour

xy平面上绘制等位线图

polar

极坐标曲线

errorbar

误差棒棒图

PlOt

直角坐标二维曲线

ezpolt

符号函数二维曲线

quiver

矢量场图

feather

沿X一轴分布的复数向量图(羽毛图)

rose

统计频率数扇块图

fplot

数值函数二维曲线

semilogx

X一轴对教坐标曲线

fill

平面多边形填色

semilogy

y一轴对教坐标曲线

gplot

绘拓扑图

stem

火柴杆国

hist

统计频率数直方图

stairs

阶梯图

 

 

 

 

 

例:误差图(errorbar

clf;x=0:0.1:4;

y=zeros(size(x));e=rand(size(x));

yu=y+e;yd=y-e;

errorbar(x,y,e)

hold on

plot(x,yu,'r-');plot(x,yd,'r-'); 

 

 

 

 

 

 

(3)  绘图工具

mmaxes prop value                         修改绘图坐标轴的属性

mmcxyorxymmcxy                 显示图上鼠标的xy坐标

mmdraw prop value                        在图上画直线

rnmfillxyzclbub      填充两条曲线间区域

mmgetxyN                                   使用鼠标获取xy坐标

mmline  prop value                          修改所画线条的属性

mmtile                                                  平铺多图形窗口

mmtext'  optional text'                  在图上放置或拖曳文本

mrnzoom                                              用橡皮框缩放坐标轴

mmzap object                                       使用鼠标删除文本,线型或坐标轴

mmfont prop value                               修改文本字体属性

 

例:

clf;x=0:0.1:4;

y=zeros(size(x));e=rand(size(x));

yu=y+e;yd=y-e;

errorbar(x,y,e)

hold on

plot(x,yu,'r-');plot(x,yd,'r-');

yu(1)=0;yu(41)=0;

fill(x,yu,'r');

yd(1)=0;yd(41)=0;

fill(x,yd,'g');  

阅读(4162) | 评论(0)


版权声明:编程爱好者网站为此博客服务提供商,如本文牵涉到版权问题,编程爱好者网站不承担相关责任,如有版权问题请直接与本文作者联系解决。谢谢!

评论

暂无评论
您需要登录后才能评论,请 登录 或者 注册