I have Python code similar to the example below to remove the top and right axes of plots created with Matplotlib. The tick marks are also removed for all plot axes.
import matplotlib.pyplot as plt
plt.close('all')
plt.figure(1)
plt.plot(x1, y1)
plt.grid()
plt.figure(2)
plt.plot(x2, y2)
plt.grid()
plt.figure(3)
plt.plot(x3, y3)
plt.grid()
ax = plt.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
plt.tick_params(axis='both', bottom='off', top='off', left='off', right='off')
plt.show()
Unfortunately, the desired effect is only applied to the last plot figure. To remove the top/right axes and tick marks for all figures, I have to place the following code after each figure:
ax = py.gca()
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
py.tick_params(...)
Is it possible to customize the axes of all figures at once using Matplotlib? I don't want to remove the axes for just one figure, I want to remove the top and right axes on all the figures without having to write .set_visible()
many times.