Python 多个子批次循环中的axvline和axhline

Python 多个子批次循环中的axvline和axhline,python,matplotlib,Python,Matplotlib,我有16个子批次,希望在每个子批次中包括以下内容: ax1.axvline(x=0.5, ymin=0.0, ymax=1.0, color='k', linestyle='--', alpha=0.3) ax1.axhline(y=0.5, xmin=0.0, xmax=1.0, color='k', linestyle='--', alpha=0.3) 运行一个循环,让它们用于所有子情节似乎比使用32行更可行,但简单的字符串串联不起作用,例如 for i in xrange(1,17,1)

我有16个子批次,希望在每个子批次中包括以下内容:

ax1.axvline(x=0.5, ymin=0.0, ymax=1.0, color='k', linestyle='--', alpha=0.3)
ax1.axhline(y=0.5, xmin=0.0, xmax=1.0, color='k', linestyle='--', alpha=0.3)
运行一个循环,让它们用于所有子情节似乎比使用32行更可行,但简单的字符串串联不起作用,例如

for i in xrange(1,17,1):
    # then try to use i for each ax -- this isn't practical

有什么建议吗?

你已经把所有东西都写好了

from matplotlib import pyplot as plt
f, ax = plt.subplots(17)

for i in range(17):
    ax[i].axvline(x=0.5, ymin=0.0, ymax=1.0, color='k', linestyle='--', alpha=0.3)
    ax[i].axhline(y=0.5, xmin=0.0, xmax=1.0, color='k', linestyle='--', alpha=0.3)

对不起,你可以发布更多的代码吗?“简单字符串连接”是什么意思?