Draw twin axes below main axes

Hi,

I want to make a plot with ordinary subplots, each of which has a
second axes set created with twinx(). Now, the second axes are
always drawn over the first, but I want the "main" data, which is
associated with the left Y axis, to be in front. (If I understand
the code correctly, the zorder doesn't help here since it only
applies to stuff within one axes set.)

I've already tried reversing the order of the two axes in figure.axes,
but that results in (apparently) only the first axes being drawn.
Is there a way to get this working?

thanks,
Georg

Hi,

I want to make a plot with ordinary subplots, each of which has a
second axes set created with twinx(). Now, the second axes are
always drawn over the first, but I want the "main" data, which is
associated with the left Y axis, to be in front. (If I understand
the code correctly, the zorder doesn't help here since it only
applies to stuff within one axes set.)

I've already tried reversing the order of the two axes in figure.axes,
but that results in (apparently) only the first axes being drawn.
Is there a way to get this working?

Reordering the axes should work. The reason for only the first axes
being shown is that the frame (white background) of the main axes
blocks the content of the twin axes.

Try something like below.

fig.axes = [ax2, ax1] # reorder
ax1.set_frame_on(False)
ax2.set_frame_on(True)

Regards,

-JJ

···

On Fri, Oct 9, 2009 at 10:55 AM, Georg Brandl <Georg.Brandl@...2819...> wrote:

thanks,
Georg

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Jae-Joon Lee schrieb:

···

On Fri, Oct 9, 2009 at 10:55 AM, Georg Brandl <Georg.Brandl@...2819...> wrote:

Hi,

I want to make a plot with ordinary subplots, each of which has a
second axes set created with twinx(). Now, the second axes are
always drawn over the first, but I want the "main" data, which is
associated with the left Y axis, to be in front. (If I understand
the code correctly, the zorder doesn't help here since it only
applies to stuff within one axes set.)

I've already tried reversing the order of the two axes in figure.axes,
but that results in (apparently) only the first axes being drawn.
Is there a way to get this working?

Reordering the axes should work. The reason for only the first axes
being shown is that the frame (white background) of the main axes
blocks the content of the twin axes.

Try something like below.

fig.axes = [ax2, ax1] # reorder
ax1.set_frame_on(False)
ax2.set_frame_on(True)

Yes, that works! Many thanks.

BTW, from Gnuplot I missed the ability to press "q" to close a figure window
and wrote a custom key handler to do that; would it make sense to add that
by default?

Georg

gui and event handling is not my field, but as far as it is easily
customizable, I guess it should be good to be added. I recommend you
to post your patch (against the lastest svn) on the dev-list and ask
how other developers think.

Regards,

-JJ

···

On Tue, Oct 13, 2009 at 2:52 AM, Georg Brandl <g.brandl@...361...> wrote:

BTW, from Gnuplot I missed the ability to press "q" to close a figure window
and wrote a custom key handler to do that; would it make sense to add that
by default?