我正试图制作一个包括7个子图的绘图。目前,我正在绘制两列,一列有四个图形,另一列有三个,就像这样:
我是按照以下方式构建这个绘图的:
#! /usr/bin/env python
import numpy as plotting
import matplotlib
from pylab import *
x = np.random.rand(20)
y = np.random.rand(20)
fig = figure(figsize=(6.5,12))
subplots_adjust(wspace=0.2,hspace=0.2)
iplot = 420
for i in range(7):
iplot += 1
ax = fig.add_subplot(iplot)
ax.plot(x,y,'ko')
ax.set_xlabel("x")
ax.set_ylabel("y")
savefig("subplots_example.png",bbox_inches='tight')
然而,对于出版物来说,我认为这看起来有点丑 - 我想做的是将最后一个子图移动到两列之间的中心。那么,调整最后一个子图的位置以使其居中的最佳方法是什么?即在3X2网格中有前6个子图,最后一个子图在两列之间居中。如果可能的话,我想保留for
循环,以便我可以简单地使用:
if i == 6:
# do something to reposition/centre this plot