hide ticks and/or labels in the presence of sharex=ax

Hi all,

how can I hide ticks and/or labels in the presence of sharex=ax. Only
the last subplot 313 should have ticks and labels.

import matplotlib.pyplot as plt
fig=plt.figure(0,figsize=(16,24))

ax = fig.add_subplot(311)
ax.set_xticks([])
ax.set_xticklabels('')

ax1 = fig.add_subplot(312,sharex=ax)
ax1.set_xticks([])
ax1.set_xticklabels('')

ax2 = fig.add_subplot(313,sharex=ax)
ax2.set_xticks(ind+width)
ax2.set_xticklabels( contname,rotation='90',fontsize=8)

Nils

ax.label_outer() will set the appropriate visibility settings for the particular subaxes depending on where it is in the grid. Just call it for each subplot being shared and you are good to go.

Cheers!
Ben Root

···

On Mon, Nov 12, 2012 at 11:43 AM, Nils Wagner <nils106@…982…> wrote:

Hi all,

how can I hide ticks and/or labels in the presence of sharex=ax. Only

the last subplot 313 should have ticks and labels.

import matplotlib.pyplot as plt

fig=plt.figure(0,figsize=(16,24))

ax = fig.add_subplot(311)

ax.set_xticks([])

ax.set_xticklabels(’’)

ax1 = fig.add_subplot(312,sharex=ax)

ax1.set_xticks([])

ax1.set_xticklabels(’’)

ax2 = fig.add_subplot(313,sharex=ax)

ax2.set_xticks(ind+width)

ax2.set_xticklabels( contname,rotation=‘90’,fontsize=8)

Nils