ticks outside the axes?

Is there anyway to place the tick marks so that they are

    > located outside the axes, i.e. on the same side of the axis
    > line as the axis labels?

    > With plots such as imshow and pcolor and even some busy
    > line plots, the interior minor ticks are completely
    > obscured and the exact location of the major ticks is
    > ambiguous.

    > It would be nice to be able to specify the ticks as inside
    > or outside (or both), right or left (or both), top or
    > bottom (or both). This functionality may already be present
    > but I cannot figure out how to invoke it if it is.

I would like to make tick placement more flexible, for example to
support a detachable tick line so the axis line, tick lines and labels
float below the axes boundary. In addition, I would like the ability
to position ticks along this line as above, centered or below, as you
suggest. But for now this doesn't exist, but you can hack an
approximation.

The tick markers are TICKUP, TICKDOWN, TICKLEFT, and TICKRIGHT,
and these are constants in matplotlib.lines. You can set the tick
markers, for example, to be TICKDOWN. But you'll have to manually
adjust the y position of the labels to be below them.

The second hack is this only works in interactive mode. ticks are
generated dynamically (eg for panning and zooming) and the ticks
aren't generated until the plot is show. In non-interactive mode, the
change of the default tick's line style is not propogating to the new
ticks that are dynamically generated when the line is shown. This
appears to be a bug so I'll look into it. For now, though, you should
be able to get something that works in non-interactive mode.

import matplotlib
matplotlib.interactive(True)
import matplotlib.lines as mpllines
import pylab as pl

ax = pl.subplot(111)
pl.plot([1,2,3])
lines = ax.get_xticklines()
labels = ax.get_xticklabels()

for line in lines:
    line.set_marker(mpllines.TICKDOWN)

# labels are in axes coords, where 0,0 is lower left of axes rectangle
# and 1,1 is upper right
for label in labels:
    label.set_y(-0.02)
pl.show()