Daniel Yang
Daniel Yang

Reputation: 43

python - matplotlib how to set every subplot x label, y label together

I don't want any subplot's label. Right now, I have to set every subplot axes one by one. Any way to set them all together.

f, ((ax1, ax2),(ax3, ax4)) = plt.subplots(2,2)
ax1.set_ylabel('')
ax1.set_ylabel('')
ax2.set_ylabel('')
ax2.set_ylabel('')
....

Upvotes: 1

Views: 1457

Answers (1)

CodeZero
CodeZero

Reputation: 1689

You could use a loop over all axes:

f, axarr = plt.subplots(2,2)
for ax in axarr.flat:
    ax.set_xlabel('')
    ax.set_ylabel('')

or even shorter:

f, axarr = plt.subplots(2,2)
for ax in axarr.flat:
    ax.set(xlabel='', ylabel='')

Upvotes: 3

Related Questions