Move xticklabels?

Jouni K Seppanen wrote:

John Hunter <jdhunter@...4...> writes:

> > Halldor Bj�rnsson <halldor@...1063...> writes:
> >> Currently the weekday label is aligned underneath the tickmark,
> >> but I would like to align the label to rhe right of the
> >> tickmark (halfway to next tick)
>
> Have you tried experimenting with the horizontalalignment property,
> which accepts left|right|center ? The default is center, which often
> looks wrong with rotated ticklabels

I think what Halldor means that it is counterintuitive to have the
weekday labels positioned at midnight. The attached example figure
shows a week's worth of data, and from a quick glance you'd imagine
that the peaks occur at night, while they really are in the afternoon.
Aligning the labels' left-hand side with the ticks would help a
little, but not nearly as much as having the labels centered between
the ticks.

Jouni is correct. Below is a small script that I have written and gets the flavor of what I am aiming for, although positions are slightly off.

It would be best to be able to keep the labels centered at given positions, and simply be able to move the label with something like

labs=get(ax,'xticklabels')
#change position of first label
pos=get(labs[0],'position')
posnew=(pos[1]+0.5, 0)
setp(labs[0],position=posnew)

This is very similar to how ticklabels can be moved around in Matlab
but it does not do anything in pylab. Is the "non-mobility" of ticklabels something that is here on purpose and cannot be changed, or is it easy to modify matplotlib to allow for this?

Sincerely,
Halldor

···

----------------------------------------------------------------------
  Halldor Bjornsson
  halldor()vedur.is tel:+354-522600
----------------------------------------------------------------------
Example where daynames are between the tickmarks but poorly aligned....
----------------------
from pylab import *
import datetime

x=arange(date2num(datetime.date.today()),date2num(datetime.date.today())+7,0.5)
y=rand(size(x))
ax=subplot(312)
p1=plot_date(x,y)
xlim(min(x),max(x))
locs=arange(min(x),max(x),1)
xticks(locs)

setp(ax,xticklabels=[])

for item in locs[0:len(locs)-1]:
      text(item+0.1,-0.1,num2date(item).strftime('%A'),fontsize=7)

show()

--