【发布时间】:2015-09-10 08:33:29
【问题描述】:
我已经使用gridspec 构建了一个 PyQt 应用程序来显示三个子图:
class Mesh(FigureCanvas):
def __init__(self, Max_i, Max_j, file='',
mesh_string='', nkx=0, nky=0, factor=1.1, figsize=(12, 8),
facecolor='none', dpi=100):
self.figure = Figure(figsize=figsize, dpi=dpi, facecolor=facecolor)
FigureCanvas.__init__(self, self.figure)
...
gs = gridspec.GridSpec(3, 4)
ax_main = self.figure.add_subplot(gs[:2, :])
ax_dx = self.figure.add_subplot(gs[2, :2])
ax_dy = self.figure.add_subplot(gs[2, 2:])
gs.update(wspace=100)
ax_dx.plot(Arr_x[: Max_i], Arr_dx, 'k-', lw=1.2)
ax_dy.plot(Arr_y[: Max_j], Arr_dy, 'k-', lw=1.2)
ax_dx.set_xlim(Arr_x[0], Arr_x[Max_i - 1])
ax_dx.set_ylim(0, Arr_dx.max() * factor)
ax_dy.set_xlim(Arr_y[0], Arr_y[Max_j - 1])
ax_dy.set_ylim(0, Arr_dy.max() * factor)
ax_dx.set_xlabel('x')
ax_dx.set_ylabel('dx')
ax_dy.set_xlabel('y')
ax_dy.set_ylabel('dy')
...
#set tight_layout here!
gs.tight_layout(self.figure)
但是,不同轴的标签仍然相互重叠,没有任何变化,似乎tight_layout()在Qt小部件中不起作用,那么还有另一种方法可以在Qt小部件中排列子图吗?
【问题讨论】:
标签: python qt matplotlib pyqt5