twinx makes a separate axes and zorders are only meaningful within a same axes.
Because ax2 is added to the figure later than the original axes,
artists in ax2 are always above others.

I don't think there is an easy way to make zorder work between several
axes, unless you somehow merge them into a single axes. You may try my
(a bit experimental) helper class made for this purpose.

http://dl.getdropbox.com/u/178748/mpl/parasite_axes2.py

import matplotlib.pyplot as plt
from parasite_axes2 import SubplotHost

f = plt.figure(2)
ax = SubplotHost(f, 1, 1, 1)
f.add_subplot(ax)

ax.plot([20,30], [0, 5], color="red", lw=5, zorder=10)
ax2=ax.twinx()
ax2.grid(ls="-", lw=5, zorder=-1)
ax2.set_axisbelow(True)

plt.show()

-JJ


On Sun, Jan 18, 2009 at 7:48 AM, Olle EngdegÄrd <o...@fysast.uu.se> wrote:
>
> Hi,
>
> Does the zorder work between twin axis? I can't get lines on the first
> axis to be on top of the second grid:
>
>
> plot([20,30], [0, 5], color="red", lw=5, zorder=10)
> ax2=twinx()
> grid(ls="-", lw=5, zorder=-1)
> ax2.set_axisbelow(True)
> title("Why doesn't the read line go above the second axis?")
>
> Cheers,
> Olle
>
> ------------------------------------------------------------------------------
> This SF.net email is sponsored by:
> SourcForge Community
> SourceForge wants to tell your story.
> http://p.sf.net/sfu/sf-spreadtheword
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
------------------------------------------------------------------------------
This SF.net email is sponsored by:
SourcForge Community
SourceForge wants to tell your story.
http://p.sf.net/sfu/sf-spreadtheword
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to