def make_split(ratio, gap=0.12):
import matplotlib.pyplot as plt
from matplotlib.gridspec import GridSpec
from matplotlib.ticker import MaxNLocator
cax = plt.gca()
box = cax.get_position()
xmin, ymin = box.xmin, box.ymin
xmax, ymax = box.xmax, box.ymax
gs = GridSpec(2, 1, height_ratios=[ratio, 1 - ratio], left=xmin, right=xmax, bottom=ymin, top=ymax)
gs.update(hspace=gap)
ax = plt.subplot(gs[0])
plt.setp(ax.get_xticklabels(), visible=False)
bx = plt.subplot(gs[1], sharex=ax)
return ax, bx
评论列表
文章目录