matlab画一个局部放大的图中图
来源:互联网 发布:网络电视电视机 编辑:程序博客网 时间:2024/05/16 15:52
第一种:magnify是个动态放大镜,固化后可以用tools>edit plot移动小图,能选取多个局部图,这个方法不错
用法:打开figure图,输入magnify,左键动态选取查看,ctrl+左键固化,也可右键固化,‘<’和‘>’缩放方法范围,‘+’和‘-’缩放放大比例。
Ever wish MATLAB had a magnifying glass so you could look at the details of a small region of your plots without having to zoom in and out again and again? Just run 'magnify.m' with the figure of interest as the current figure, then use the left mouse button to bring up a magnified veiw that you control. Or use the 'Ctrl' key while clicking to bring up a magnifying glass that 'locks' onto the figure when released (for use when copying and printing figures). Use the '<' and '>' keys to make the magnifying glass smaller or larger. Use '-' and '+' to decrease or increase the magnification level.
网上一般有三种方法在MATLAB中做图中图,但是我感觉使用magnify是magnify是个动态放大镜,固化后可以用tools>edit plot移动小图,能选取多个局部图。下面详细讲解其使用方法:
1、下载magnify,官网下载地址http://www.mathworks.com/matlabcentral/fileexchange/5961-magnify
2、下载后将文件放到当前figure目录下(也就是当前工作区间中)。
3、打开figure图,输入magnify,然后右键选中想要放大的区域(按着右键不要动),然后可以使用‘<’和‘>’缩放方法范围,‘+’和‘-’缩放放大比例,看着放大的小图满意后松开右键即可。(这一过程网上都管他们叫固化)
4、然后用tools>edit plot就可以移动小图到你想放在的地方了。
f1=figure; plot(1:100,randn(1,100),(1:300)/3,rand(1,300)), grid on, magnify(f1) % You must complete the amplification in the figure before you run the next code.Assuming we just magnify once. d=get(f1,'Children'); d(1).Position=[0 0.5 d(1).Position(3) d(1).Position(4)];%Move the magnified figure to the specific position axis = d(2); rectangle('Position',[d(1).XLim(1),d(1).YLim(1),d(1).XLim(2)-d(1).XLim(1),d(1).YLim(2)-d(1).YLim(1)],'LineWidth',2,'LineStyle','--','EdgeColor','r')%Mark the magnified part in the original figure.http://cn.mathworks.com/matlabcentral/fileexchange/5961-magnify
第二种:用起来也很方便,缺点是只能框选一处,不能选取多个。
美国学者Duane HanselmanandBruce Littlefield编写的MasteringMATLAB7上的例子,实现图中图缩放功能,使用了3个函数,这三个函数在附件中,当然也可以到网站http://www.eece.maine.edu/mm/去下载。
函数简单介绍:
getn()将get()函数的输出参数简化为单个变量;
getbox()实现矩形区域的选择,并捕捉该区域的横纵标的范围
mmzoom创建一个缩放坐标轴。
试图做了例子,传上来一起分享。
例子:
代码;figure(1);h2=axes('position',[0 0 1 1]);axis(h2);x2=0:pi/50:2*pi;y2=sin(x2);h3=plot(x2,y2,'b-');h1=axes('position',[0.3 0.2 0.4 0.4]);axis(h1);x1=0:pi/50:2*pi;y1=cos(x1);h4=plot(x1,y1,'r-');hold onh=[h3; h4];str=['大图中的曲线';'小图中的曲线'];legend(h,str);
看下来,还是倾向第三种使用axes方法放大局部图像的方法,关于axes的详细解释见
http://5460521xp.blog.163.com/blog/static/6908756920122210253741/
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函数后的参数说明,以横纵坐标量程为基准:
例中0.18为子图左下角的归一化横坐标位置:
同理,0.62为子图左下角的归一化纵坐标位置:
0.28为子图的归一化宽度,0.25为子图的归一化高度,具体计算过程同上
下面通过绘制 y=1/(t-3) 的曲线举例说明该函数的使用方法。程序如下: clc;clear;close all; t=linspace(0,6,300);% 生成曲线的整体离散坐标值tt1=linspace(2.8,3.2,300); % 生成曲线的局部离散坐标值t1 y=sin(1./[t-3]);% 生成曲线的整体离散函数值yy1=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)]); % 设置坐标轴范围
- Matlab画一个局部放大的图中图
- matlab画一个局部放大的图中图
- matlab画一个局部放大的图中图
- matlab画一个局部放大的图中图(总结)
- matlab画一个局部放大的图中图(转)
- 在MATLAB的figure图中画局部放大的图中图
- Matlab局部放大_20170815
- Matlab绘图程序局部放大
- matlab图像局部放大算法
- matlab读取txt,excel文件数据,图中图,局部放大
- 局部放大的功能
- Js局部放大的效果
- 实现图像的局部放大
- matlab-figure图形( 局部放大&变坐标)
- 图片的局部放大的效果实现
- 对图像的局部进行放大
- js 实现 图片的局部放大效果
- js、jquery图片的局部放大
- 机器学习15-k-均值算法表述
- 基于邻接矩阵的无向图构造,以及宽度优先、深度优先搜索(Java)
- string与long long的区别
- Spring开发环境搭建
- 定义指针变量时星号的位置
- matlab画一个局部放大的图中图
- 锁的概述
- 第一次使用阿里云(Windows)部署Java后台
- jQuery ajax使用$(this).parent()无效解决方法
- Ubuntu系统下arm-linux-gcc交叉编译环境搭建过程
- 如何为一些常用的工具开启启动快捷键。比如截图工具,qq,浏览器等。
- Linux 启动 ./XX.sh 文件
- java单例
- 使用 Rx 中预定义的 Subject