如果您想删除轴脊,但不想删除其他信息(刻度、标签等),您可以这样做:
fig, ax = plt.subplots(7,1, sharex=True)
t = np.arange(0, 1, 0.01)
for i, a in enumerate(ax):
a.plot(t, np.sin((i + 1) * 2 * np.pi * t))
a.spines["top"].set_visible(False)
a.spines["right"].set_visible(False)
a.spines["bottom"].set_visible(False)
或者,更容易地,使用seaborn http://stanford.edu/~mwaskom/software/seaborn/:
fig, ax = plt.subplots(7,1, sharex=True)
t = np.arange(0, 1, 0.01)
for i, a in enumerate(ax):
a.plot(t, np.sin((i + 1) * 2 * np.pi * t))
seaborn.despine(left=True, bottom=True, right=True)
两种方法都会为您提供: