Fork me on GitHub

使用axes函数在matlab绘图中实现图中图的绘制

使用axes函数在matlab绘图中实现图中图的绘制  

 

有时为了对细节进行详细说明,需要在一个较大坐标轴上绘制一个小图来对局部进行放大以阐述结果。

这可以通过调用axes函数实现。

下面通过绘制 y=1/(t-3) 的曲线举例说明该函数的使用方法。

程序如下:

                                                                                                                                                            
clc;
clear;close all;                                                                                                               
t=linspace(0,6,300);% 生成曲线的整体离散坐标值t

t1=linspace(2.8,3.2,300); % 生成曲线的局部离散坐标值t1 

                                                                                                                               
y=sin(1./[t-3]);% 生成曲线的整体离散函数值y

y1=sin(1./[t1-3]); % 生成曲线的局部离散函数值y1

                                                                                                                                   
figure;% 生成新的图形窗口  
 
         
plot(t,y);axis('equal'); % 绘制整体曲线图    

                                                                                           
axes('Position',[0.18,0.62,0.28,0.25]); % 生成子图   

                                                                           
plot(t1,y1); % 绘制局部曲线图                                                                                                                
xlim([min(t1),max(t1)]); % 设置坐标轴范围                                                                                            

 

使用axes函数在matlab绘图中实现图中图的绘制 - 流星萍儿 - 绛珠草的天空

 

axes函数后的参数说明,以横纵坐标量程为基准:

例中0.18为子图左下角的归一化横坐标位置:

    (该位置的横坐标-横坐标起始值)/横坐标量程=0.18,

同理,0.62为子图左下角的归一化纵坐标位置:

     (该位置的纵坐标-纵坐标起始值)/纵坐标量程=0.62,

0.28为子图的归一化宽度,0.25为子图的归一化高度,具体计算过程同上

posted @ 2016-04-18 23:32  stardsd  阅读(6862)  评论(0编辑  收藏  举报