MATLAB中subplot绘图相关技巧

2023-11-05

http://xiaotingzi.blog.163.com/blog/static/217769214201361981535727/

The first thing I want to mention is that tightfig has a different purpose than the other entries. The description on the entry page explains the purpose very well: "Alters a figure so that it has the minimum size necessary to enclose all axes in the figure without excess space around them." Note that this is about making the outer bounds of the figure tight. Its intention is not to modify any of the spacings between the axes, which is the primary purpose of the other entries. I'll say more on this later.

figure('Color', [.8 .8 .8]);

subplot(2,2,1);
surf(peaks); shading interp
title('Peaks');
ylabel(colorbar, 'Color Scale');

subplot(2,2,2);
plot(rand(10,3));
xlabel('time');
ylabel('money');

subplot(2,2,3);
imshow('peppers.png');

subplot(2,2,4);
surf(membrane(1));
xlabel('x label');
ylabel('y label');
zlabel('z label');

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

tightfig is extremely simple to use. You just call it after creating your plots, and it applies to the current figure. That's one of my favorite things about this entry.

tightfig;

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

Review of the other entries

Before looking into the other entries, I'd like to point out that the use case for tightfig is quite different from that of the others. One is for tightening the figure boundary, and the others are for controlling/tightening the axes boundaries. So it may not be an apples-to-apples comparison. Nonetheless, here I go. Oh, and try not to get confused with all the names. :)

subplot_tight

I find subplot_tight to be the easiest to use, since it has a syntax that is closest to the MATLAB functionsubplot. Not surprisingly, it is a wrapper around subplot, with an added option to specify the spacing between an axes and its neighbors. Because it's a wrapper, you can make use of the vector input syntax for the 3rd parameter (see below). The author also supplies a demo script to recreate his screenshot.

figure;
subplot_tight(2, 2, 1, .1);
subplot_tight(2, 2, 2, .05);
subplot_tight(2, 2, [3 4], .05);

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

tight_subplot and subplot1

tight_subplot and subplot1 are quite similar. They both allow you to lay out a grid of subplots with arbitrary spacings and margins. tight_subplot is compact with just those parameters, i.e. spacing and margin, whilesubplot1 lets you control other axes properties, such as tick labels, label font size, and axes scale. I like that it gives me the ability to have the tick labels only displayed on the outside with subplot1 (see example below).

% tight_subplot

figure;
hA = tight_subplot(3, 2, [.01 .03], [.1 .01], [.01 .01]);

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

% subplot1

figure;
subplot1(3, 2, 'Gap', [.01 .03], 'XTickL', 'Margin', 'YTickL', 'Margin');

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

spaceplots

spaceplots works like tightfig, in that you create your figure first with subplots, then call spaceplots to adjust the spacings and margins. This function, unlike tightfig, will allow you to adjust the spacings between axes, not just the outside margin. The part that I like most is that it will work with irregular-grid subplots (see example below). However, there's a caveat that it only works on axes created using subplot.

figure;
subplot(2, 2, [1 2]); plot(rand(10, 3));
subplot(2, 2, 3); surf(peaks); title('Peaks')
subplot(2, 2, 4); contourf(peaks);

% 0 margin, 0.02 (normalized) spacing
spaceplots([0 0 0 0], [.02 .02]);

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

subplotplus

subplotplus is the king of custom subplots. It comes with a price of somewhat cryptic syntax, but once you understand it (with the help of an example script), it can let you custom layout your subplots in any configuration you like. It even includes the ability to "glue" axes together so that they have a common axis.

cell71={{['-g']};{['-g']};{['-g']};{['-g']};{['-g']};{['-g']};{['-g']}};
cell41={{['-g']};{['-g']};{['-g']};{['-g']}};

figure;
C = {{{{[]},{[]}};cell41},cell71};
[h,labelfontsize] = subplotplus(C);

Matlab中控制图像显示边界、subplot间距等 - 婷子 - 浪漫樱花

Conclusion

So what have I concluded from this review? There are multiple solutions to a problem! They all have unique ways of tackling the problem, and some solve a slightly different problem than others. Overall, I prefer the "post-processing" type functions, tightfig and spaceplots. I tend to do my exploratory plotting in a rough state, and once I have a plot I like, then I start making things look nicer. But of course, with an interactive tool like MATLAB, even the "pre-processing" type functions can be introduced at a later step.

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

MATLAB中subplot绘图相关技巧 的相关文章

  • 分段,分页与段页式存储管理

    一 分页存储管理 1 基本思想 用户程序的地址空间被划分成若干固定大小的区域 称为 页 相应地 内存空间分成若干个物理块 页和块的大小相等 可将用户程序的任一页放在内存的任一块中 实现了离散分配 1 等分内存 页式存储管理将内存空间划分成等
  • Go 定时器(timer)

    创建一个定时器 package main import fmt time func main timer time NewTimer time Second 3 3秒定时器 fmt Printf timertype timer fmt Pr
  • Mysql 8配置驱动

    1 依赖的注入 spring datasource url jdbc mysql localhost 3306 你的数据库名 useUnicode true characterEncoding utf 8 serverTimezone As
  • SpringBoot中的注解@SpringBootApplication和(@Configuration......)

    以下选自官方的文档 这里写链接内容 Many Spring Boot developers always have their main class annotated with Configuration EnableAutoConfig
  • Ping报文分析

    打开Windows虚拟 执行ipconfig的操作 用Kali执行Ping操作 并用Kali自带wireshark分析 可以看到Ping报文发送的是ICMP数据报文 通过网上查阅资料可知 ICMP报头格式 ICMP报文包含在IP数据报中 I
  • yolov5使用

    参考网址 https zhuanlan zhihu com p 501798155 源码下载及使用 release下载source及pt文件 yolov5s pt https github com ultralytics yolov5 ta
  • c# 连接Oracle数据库必须安装客户端吗

    以下方案在oracle9 10上测试通过 其他版本恕不一一测试 复制以下几个文件 从oracle xe 10g中提取的 到应用程序根目录即可 若有使用tns 请再建立tnsnames ora文件 oci dll ociw32 dll ora
  • 【Excel VBA】得到最后数据的行数

    纲举目张 得到最后数据的行数 说明 代码 code 解析 拓展 得到最后数据的行数 说明 在编写代码时我们时常用到的是 取得数据表的最后一行数据所在的行号 这样在编写循环语句时就不用猜着自定义终止值 代码 code Dim FinalRow
  • Vue 的实用开发技巧

    文章目录 v for 中使用 key 何时使用何种key 所以使用 index 作为 key 需要满足 哪何时使用 id 作为 key 呢 v if v else if v else 中使用 key 使用条件 例子 v for 和 v if
  • 共享DLL中使用MFC 和在静态库中使用MFC

    使用VS2008 在项目属性中有一项MFC的使用 有三种设置 1 使用标准Windows库 2 在共享DLL中使用MFC 3 在静态库中使用MFC 第一种顾名思义 第二种指的是打包时一些MFC的DLL的内容没有被包含在EXE文件中 所以EX
  • 树莓派4B 安装preem-PT 实时系统那些坑

    拿到一个树莓派之后 最好uname a 看一下内核版本号 比如同样的树莓派4B 不同出厂批次和时间 是有一定改动的 比如有些是4 14 4 19 而有些是5 4 5 15 等 较新的树莓派如果向下刷固件 比如用树莓派最新的4B 刷ubunt
  • ZooKeeper集群环境搭建

    大数据学习记录篇 持续更新中 个人主页 beixi 本文章收录于专栏 点击传送 大数据学习 持续更新中 感谢各位前辈朋友们支持学习 文章目录 1 ZooKeeper集群环境介绍 2 搭建环境准备 3 搭建步骤 1 ZooKeeper集群环境
  • 网络安全事件应急响应实战

    一 应急响应 1 Window入侵排查 当企业发生黑客入侵 系统崩溃或其它影响业务正常运行的安全事件时 急需第一时间进行处理 使企业的网络信息系统在最短时间内恢复正常工作 进一步查找入侵来源 还原入侵事故过程 同时给出解决方案与防范措施 为
  • hyper-v开启与关闭

    1 控制面板 2 服务 以管理员身份运行msconfig 3 cmd命令 以管理员运行 开启 上次关闭docker服务时 重新启动虚拟化技术执行了上面个两个步骤 未执行下面命令 检查了好久查了网上的资料才想起来 bcdedit set hy
  • java 遍历map 方法 集合 五种的方法

    package com jackey topic import java util ArrayList import java util HashMap import java util Iterator import java util
  • git如何克隆代码

    首先你要去官网安装 Git Downloads 下载好了一直下一步就行 找到一个装文件的文件夹右击 点击git bash here 然后 git clone 加上git上的网址 回车就可以下载了 希望有帮助到你
  • crm服务器 系统盘,crm搭建云服务器

    crm搭建云服务器 内容精选 换一换 购买多台云服务器时 有以下两种方式设置有序的云服务器名称 自动排序 购买多台云服务器时自动按序增加4位数字后缀 正则排序 按照name prefix begin number bits name suf
  • Windows系统缺失crypt32.dll文件导致程序无法运行解决办法

    其实很多用户玩单机游戏或者安装软件的时候就出现过这种问题 如果是新手第一时间会认为是软件或游戏出错了 其实并不是这样 其主要原因就是你电脑系统的该dll文件丢失了或没有安装一些系统软件平台所需要的动态链接库 这时你可以下载这个crypt32
  • JDBC的两种实现方法及区别

    文章目录 toc JDBC 一 JDBC简介 二 通过DriverManager实现JDBC 三 通过DataSource实现JDBC 四 DataSource和DriverManager的区别 JDBC 一 JDBC简介 JDBC Jav
  • JPA最终对象转换为sql的位置

    这里以spring data jpa 3 1 1版本为例 Jpa最终是采用的hibernate进行数据库查询 因此其最终由对象转为sql的语句可以在 类ConcreteSqmSelectQueryPlan gt 方法listInterpre

随机推荐

  • openMPI在Linux环境下的安装和部署

    Linux环境背景 CentOS7 安装步骤 进入官网openmp org 下载压缩包openmpi 4 1 4 tar gz 将openmpi 4 1 4 tar gz放到 opt文件夹内 解压tar zxvf openmpi 4 1 4
  • vscode ~~出现黄色波浪线,解决办法~

  • SPSS(八)logistic回归(图文+数据集)

    SPSS 八 logistic回归 我们之前的线性回归也好 线性回归衍生方法也好 非线性回归也好 因变量的类型都是连续性的 假如因变量的类型是分类的呢 logistic回归针对的是二分类的因变量 logistic回归 基于线性回归模型发展而
  • VS2010每次调试都出现“此项目已经过期”提示

    问题描述 最近因为项目需要 开发平台从VS2005切换成了VS2010 把一些老项目也转换到VS2010平台 因为是从低到高升级 微软还是做了很多兼容 基本上可以无缝切换 编译调试也基本正常 但是发现有些项目 尤其是比较大的项目 刚刚编译完
  • 1.linux安装oracle12c及测试连接(详细讲解)

    1 虚拟机配置 系统Centos7 6 CPU 4H 内存 4G 硬盘 128G GUI 有 2 安装前准备 2 1配置静态IP 我们是安装服务 一个服务主机IP地址不应该的变化的 所以设置为静态 vim etc sysconfig net
  • 算法练习之反转链表

    比较久没有写算法题了 还是应该复习回顾一下 这次用新学的 rust 语言来解决算法问题 个人认为学习算法题目重要的不是解法 而是解法背后的思想 要从每一道题目中学习到解决问题的思路 定义一个函数 输入一个链表的头节点 反转该链表并输出反转后
  • Cortex-M3与Aurix的堆栈

    1 在ARM Cortex M3架构中 堆栈通常由两个寄存器来管理 主堆栈指针 MSP 和进程堆栈指针 PSP 1 1 MSP是处理器的默认堆栈指针 用于保存中断处理程序的现场 当芯片复位或发生中断时 处理器会自动将MSP的值保存到堆栈中
  • javascript之我见

    首先 须知JavaScript之出处 乃ECMAScript之变体也 诞生于1995年 为Sun Microsystems所开发 其初衷在于使得网页具有动态交互功能 诸君须知 时乃互联网方兴未艾之际 JavaScript之出 犹如孔子之出
  • 机器学习:伦敦出租车示例(数据分析,数据处理)

    原地址 http ju outofmemory cn entry 299056 记得有一个出租车对于数据分析是很好的参考范例 找找转发过来以后参考 在纽约 出租车分为两类 黄色和绿色 黄色出租 Yellow TAXI 车可以在纽约五大区 布
  • 硬件系统工程师宝典(38)-----常用接口之视频接口的电路设计

    各位同学大家好 欢迎继续做客电子工程学习圈 今天我们继续来讲这本书 硬件系统工程师宝典 上篇我们介绍了一些常用的接口带EMC保护的电路设计 有AC24V AC110 220V AV接口 CAN接口 DC12V DC24V DC48V接口 今
  • fread 读文件问题(csdn)

    http topic csdn net t 20030912 21 2254341 html fread 返回的是所有被读取的字节数 假如数目不等于请求的字节数 说明有错误发生或者到达文件结束标志 End of File 下面写了个读取完整
  • 最小二乘法ols 系数 a、b 计算公式

    对于拟合函数 Y a bX 求解 a b 需要先求出b再求a 分子分母同时除n得到 上面的公式就是网上常看到的计算b的公式
  • k型热电偶材料_常见热电偶大集合,说不定对你有用

    温度是工业自动化中的一个重要参数 温度仪表一般分接触式测量仪表与非接触式测量仪表 现代接触式温度仪表又以热电阻和热电偶为主 热电阻和热电偶分类方法很多 不过一般以材质进行分类 今天我们就来看一下常见热电偶种类 热电偶 如下图所示 热电偶是两
  • 如何免费复制百度文库上的文字

    场景 复制百度文库上的文字 一般是收费的 解决方案 按 F12 点击设置 禁用JavaScript 即可复制
  • [leetcode] 432. 全 O(1) 的数据结构

    题目链接 之前没有做过这种类型的题目 看到的时候一脸蒙圈 看了官方题解之后 了解到这个是双向链表 然后来写一下题解 我们可以维护一个链表 这个链表是一个双向的 把这个链表维护成从头节点到尾节点是单调递增的 然后我们就可以很好的通过头尾返回出
  • Ubuntu 16.04下Anaconda的安装及使用

    文章目录 一 Anaconda的下载及安装 1 下载Anaconda 2 安装Anaconda 3 配置清华镜像源 二 Anaconda的基本使用 1 管理conda版本 2 管理虚拟环境 3 安装第三方包 三 Anaconda的卸载及重装
  • 【MySQL数据库的学习】

    MySQL数据库 1 连接数据库 mysql u root p 123456 2 创建数据库 create database 数据库名称 以字母 数字 下划线组成的字符串 但不要以数字开头 3 查看数据库 show databases 4
  • 内网和外网的区别是什么?

    内网和外网的区别重要依据主要是判断它是不是与广阔的外界相连 内网和外网最大的区别 内网IP局域网 网线都是连接在同一个 交换机上面的 也就是说它们的IP地址是由交换机或者路由器进行分配的 而且每一个IP也是有所不同的 并且这些连接在同一个路
  • 解决“error C267 ‘Beep_Led_yellow‘ requires ANSI-style prototype”错误方法

    今天给大家分享一个大家可能经常见的错误提示 error C267 Beep Led yellow requires ANSI style prototype 错误原因 这个错误其实是因为是指你的函数没有形参 却在使用过程中使用了值 就是比如
  • MATLAB中subplot绘图相关技巧

    http xiaotingzi blog 163 com blog static 217769214201361981535727 The first thing I want to mention is that tightfig has