I am working on a time-series data browser based on matplotlib. In general, it shows a N_row x 1_col stack of axes, which share the x axis, the time axis. It is nice that matplotlib offers the sharex option so that the data can be zoomed simultaneously in time. However, one problem with the sharex option is that it not only shares the axis range (or limits, if you will), but also the axis appearance, which is not always desirable. In my case, I want the tick labels to be shown only on the bottom subplot. However, that doesn’t seem to be achievable with sharex.

ax1.get_xaxis().set_ticklabels([]) # This also suppresses x tick labels of ax2.

fig.canvas.draw()

#-------------------------- end of code ------------------------------------

Is there a workaround, hopefully simple and straightforward, to share range (or limits) only among axes? Better yet, can this feature be added, like a keyword sharexrange, in the future, if it is not already there? Of course, the situation should be similar for y axis, too.

On Fri, Oct 5, 2012 at 5:44 PM, Jianbao Tao <jianbao.tao@...287...> wrote:

Hi,

I am working on a time-series data browser based on matplotlib. In general,
it shows a N_row x 1_col stack of axes, which share the x axis, the time
axis. It is nice that matplotlib offers the sharex option so that the data
can be zoomed simultaneously in time. However, one problem with the sharex
option is that it not only shares the axis range (or limits, if you will),
but also the axis appearance, which is not always desirable. In my case, I
want the tick labels to be shown only on the bottom subplot. However, that
doesn't seem to be achievable with sharex.

The follow snippet demonstrates my example: #------------------------- code --------------------------------------------
import matplotlib.pyplot as plt
fig = plt.figure()
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212, sharex=ax1)

ax1.get_xaxis().set_ticklabels() # This also suppresses x tick labels of
ax2.
fig.canvas.draw() #-------------------------- end of code ------------------------------------

Is there a workaround, hopefully simple and straightforward, to share range
(or limits) only among axes? Better yet, can this feature be added, like a
keyword sharexrange, in the future, if it is not already there? Of course,
the situation should be similar for y axis, too.

Thank you very much.

Jianbao

--
Damon McDougall http://www.damon-is-a-geek.com
B2.39
Mathematics Institute
University of Warwick
Coventry
West Midlands
CV4 7AL
United Kingdom