I did this like this:
from mpl_toolkits.axes_grid.parasite_axes import SubplotHost
fig = plt.figure(1, figsize=(figwidth,figheight))
ax = SubplotHost(fig, 1,1,1)
fig.add_subplot(ax)
#plotting as usual
ax2 = ax.twin() # ax2 is responsible for "top" axis and "right" axis
ax2.axis["right"].toggle(ticklabels=False)
ax2.xaxis.set_major_formatter(FuncFormatter(fmt_zToEta)) #set eta coord format
#with a function for the Z to eta transform for plot labels
def fmt_zToEta(x, pos=None):
#...
return transformed_label
I also remember starting off with that redshift example ;-)
I think the SubPlotHost
thing is necessary, but I'm not 100% sure, since I ripped this out of an existing (sub)plot of mine without checking if it runs nicely without.
Edit: also, see https://stackoverflow.com/a/10517481/599884