This script _almost_ works for me:
import datetime
import matplotlib.numerix as nx
from matplotlib.dates import date2num, DateFormatter, HourLocator
from pylab import *
# Plot some example data
figure()
dmin = date2num(datetime.datetime(2006,03,29))
plot(nx.arange(dmin, dmin+7, 0.1), cumsum(rand(70)), 'r-')
# Label midnights and noons with the weekday
xax = gca().xaxis
setp(xax, 'major_formatter', DateFormatter('%a'))
setp(xax, 'major_locator', HourLocator(byhour=(0,12)))
# Hide every other tick; for some reason this means every _fourth_ tickline
setp(getp(gca(), 'xticklines')[::4], 'visible', False)
# Hide every other label; this is really every second object in the sequence
setp(getp(gca(), 'xticklabels')[1::2], 'visible', False)
show()
By "almost" I mean that the script doesn't work if I run it (using
e.g. %run foo.py in ipython) but, weirdly, it does work if I paste it
into ipython. The problematic line is the one that sets some
xticklines' visibility to False: within a script it hides all tick
lines, entered in ipython it hides every other line. (This is with
Matplotlib svn 2239, IPython 0.6.15, Python 2.4.1 "official unofficial
framework build", OS X 10.4.5, WXAgg.)
···
--
Jouni