Matlab绘制图组
前言
我们在用Matlab的subplot函数绘制图组时可能会发现子图之间的间距不太好看,可以通过set('Position', [l, b, w, h])函数来分别调整,比较麻烦,这里我写了一个函数subplot_adjust来简化这一过程。
用法
function subplots_adjust(row, col, varargin)
Tune the subplot layout.
The parameter meanings (and suggested defaults) are
left = 0.12 # the left side of the subplots of the figure
bottom = 0.138 # the bottom of the subplots of the figure
width = 0.8 # the width of the subplots of the figure
hight = 0.78 # the hight of the subplots of the figure
wspace = 0.12 # the amount of width reserved for space between subplots,
# expressed as a fraction of the average axis width
hspace = 0.1 # the amount of height reserved for space between subplots,
# expressed as a fraction of the average axis height
supPosition = [0.075, 0.08, 0.9, 0.85]
# [left, bottom, width, hight]
# super axes position, which controls position of
# supxlabel, supylabel and suptitle.
在用subplot画完图组后,直接在最后面加上subplot_adjust即可,例如:
1 | |
绘制2行1列图组,设置两子图之间纵向间距为0,结果如下:
源码
1 | |
Matlab绘制图组
https://ting2938.github.io/程序设计/Matlab/Matlab绘制图组/