hbars with different labels left and right

Hi list members!

I'm not sure if this is bad style or anything but I'm trying to do
something like in this example:
http://matplotlib.sourceforge.net/examples/pylab_examples/barchart_demo2.html

I would like to haver different labels on both sides.
a) I tried using the twinx() command like in that example but the axes
seem to be scaled differently i.e. the ticks on the right don't have the
same spacing as on the left.

Sample code is here:
http://paste.pocoo.org/show/247636/

b) Is it necessary to do that with twinx() or is there a way to set the
labels for both sides independently?

Best
Simon

a) I tried using the twinx() command like in that example but the axes
seem to be scaled differently i.e. the ticks on the right don't have the
same spacing as on the left.

twinx() creates an axes whose y-axis is independent from the original axes.

b) Is it necessary to do that with twinx() or is there a way to set the
labels for both sides independently?

Within a same axes, you cannot change the ticklabels of one side
without affecting the other side. This is also true between two axes
with shared axis.

One option would be to sync the limits of two axis manually (or
automatically using event). Another option you may consider is to use
the axes_grid1 toolkit (assuming that you're using mpl v1.0).

    from mpl_toolkits.axes_grid1.parasite_axes import SubplotHost

    fig = plt.figure()
    ax = SubplotHost(fig, 111)
    fig.add_subplot(ax)

    ax2 = ax.twin() # "twin", not "twinx"
    ax2.axis["top"].toggle(ticklabels=False) # make ticklabels at top invisible

    ax2.set_yticks([0.,0.5, 1.])
    ax2.set_yticklabels(["A", "B", "C"])

-JJ

···

On Sun, Aug 8, 2010 at 10:38 PM, Simon Friedberger <simon+matplotlib@...3202...> wrote: