拓新分享 http://blog.sciencenet.cn/u/DanYangpeng

博文

修改MatLab子图的横纵坐标范围或Legend

已有 4962 次阅读 2020-5-29 18:30 |个人分类:MatLab|系统分类:科研笔记| MatLab, 子图句柄

MatLab中已经绘好包含若干个子图的figure,如果要调整每个子图的横纵坐标范围或Legend,可以尝试这样做:


figure(1),h1=get(gcf);   %获得当前figure的句柄

set(h1.Children(8),'ylim',[0,1],'xlim',[0,3]); %假设有4个子图,这里是调整第1个子图的横纵坐标范围为[0,3],[0,1]

set(h1.Children(7),'string',{'x1','x2','x3'},'location','northwest'); % 修改第1个子图的legend为(x1,x2,x3),并放在子图的左上角


如下图1,当前figure句柄h1的Children域倒序保存了每个子图的axes和legend对象,比如第1个子图的legend和axes分别放在倒数第2、倒数第1个元素中,如图2所示。

图1 句柄h1的Children域保存了子图的legend和axes对象


图2 Children中子图的legend和axes是倒序存放的


图3给出了修改第1个子图legend后的属性

图3 第1个子图legend






https://blog.sciencenet.cn/blog-2578568-1235560.html

上一篇:解决Latex无法编译的Error:Could not start the command: pdflattex.exe
下一篇:修改MatLab子图的Grid
收藏 IP: 59.172.176.*| 热度|

0

发表评论 评论 (0 个评论)

数据加载中...

Archiver|手机版|科学网 ( 京ICP备07017567号-12 )

GMT+8, 2024-7-18 10:29

Powered by ScienceNet.cn

Copyright © 2007- 中国科学报社

返回顶部