Axes on top of graphs

Hi,

using the PS Backend and matplotlib 0.82 with python 2.3.5 I have the
problem that my graphs typically show up on top of the axes lines (the
figure frame) and tick marks. However, for a journal quality figure, I
need the axes and the tick marks to be on top of the graph(s).

I looked through the archives and found below e-mail. Has there been
any progress in fixing this? Has Michael Brady submitted a patch?

Thanks.

- Christian

···

*****************************************************************

     > I tried setting the z-order of the tick objects, but it
     > looks to me like the ticks are hard-coded to always draw
     > before (underneath) any lines or patches.

That"s right, they are. This is a bug and not a feature :frowning:

The ticks are drawn as part of the Axis. See
matplotlib.axes.Axes.draw, eg

         if self.axison:
             self.xaxis.draw(renderer)
             self.yaxis.draw(renderer)

The Axis instances (XAxis and YAxis) are comprised of Line2D (the
ticks) and Text (the labels) instances.

     > Is there a way to tell the Axes to draw the ticks on top
     > of any Polygons instead of underneath?

As noted above, before any of the zorder sorting is done, the xaxis
and yaxis are drawn. One possible solution is to move the axis
drawing commands to the
end of the Axes.draw function. Off the top of
my head, I don"t see any problem with this approach. Typically, you
want the ticks visible. We"ve talked in the past on the dev list
about the desirability in supporting ticking inside, center or outside
the axes box, but it hasn"t been implemented yet.

Vis-a-vis zorder sorting, a more general solution would be to have a
method which extracts the Artist primitives (Line2D and Text) from the
XAxis and YAxis and adds them to the sort, but I"m not sure if this is
actually better. In real life, I think you always want them on top.
Right?

     > If not, it doesn"t look like it would be too hard to
     > modify Axes.draw() to respect the z-order of ticks. I"m
     > happy to do this, although I"m nervous that it might
     > break stuff that assumes that ticks are always drawn
     > before everything else. John, do you recommend that I
     > create such a mod?

Yes, if you can find something that works, and behaves sanely over the
poorman"s unit tests in examples/backend_driver.py.

JDH

Hi,

sorry about my previous e-mail. I have now tried the same with 0.85.
The tick marks are now by default on top of the data graphs while the
axes lines (please correct my vocabulary usage here, axes lines =
figure frame?) are still below.

To get the figure frame drawn on top of everything, one
has to modify axes.draw. Namely, one adds to

         if not self._axisbelow:
            if self.axison and not inframe:
                self.xaxis.draw(renderer)
                self.yaxis.draw(renderer)

these 4 lines:

            if self.axison:
                if self._frameon:
                    self.axesPatch.set_fill(False)
                    self.axesPatch.draw(renderer)

. Also, one has to set gca.set_axisbelow(False) for the if block
to be executed.

The additional code draws another figure frame, this time without
filling, on top of the previous one and the data graphs.

- Christian

···

On 11/19/05, Christian David Ott wrote:

Hi,

using the PS Backend and matplotlib 0.82 with python 2.3.5 I have the
problem that my graphs typically show up on top of the axes lines (the
figure frame) and tick marks. However, for a journal quality figure, I
need the axes and the tick marks to be on top of the graph(s).

I looked through the archives and found below e-mail. Has there been
any progress in fixing this? Has Michael Brady submitted a patch?

Thanks.

- Christian