ax.grid(True)

ax.gridlines.set_visible(False) # this is just to make code works with future mpl.

ax.xaxis.set_visible(True)

ax.xaxis.set_zorder(2.6)

ax.yaxis.set_zorder(2.6)

ax.yaxis.set_visible(True)

for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks:

t.gridOn = True

t.tick1On = False

t.tick2On = False

t.label1On = False

t.label2On = False

plt.show()

Here is a complete example, a modified version of simple_axisline2.py

import matplotlib.pyplot as plt

from mpl_toolkits.axes_grid.axislines import SubplotZero

import numpy as np

fig = plt.figure(1, (4,3))

# a subplot with two additiona axis, "xzero" and "yzero". "xzero" is

# y=0 line, and "yzero" is x=0 line.

ax = SubplotZero(fig, 1, 1, 1)

fig.add_subplot(ax)

# axes.toggle_axisline(False)

# make xzero axis (horizontal axis line through y=0) visible.

ax.axis["xzero"].set_visible(True)

ax.axis["xzero"].label.set_text("Axis Zero")

ax.axis["xzero"].label.set_bbox(dict(boxstyle="round",ec="r", fc="w"))

ax.axis["xzero"].major_ticklabels.set_bbox(dict(boxstyle="square",

ec="none", fc="w", alpha=0.5))

# make other axis (bottom, top, right) invisible.

for n in ["bottom", "top", "right"]:

ax.axis[n].set_visible(False)

xx = np.arange(0, 2*np.pi, 0.01)

ax.plot(xx, np.sin(xx))

ax.grid(True)

ax.gridlines.set_visible(False) # this is just to make code works with future mpl.

ax.xaxis.set_visible(True)

ax.xaxis.set_zorder(2.6)

ax.yaxis.set_zorder(2.6)

ax.yaxis.set_visible(True)

for t in ax.xaxis.majorTicks + ax.yaxis.majorTicks:

t.gridOn = True

t.tick1On = False

t.tick2On = False

t.label1On = False

t.label2On = False

plt.show()