Matplotlib 1.2.0, Windows Vista, Python 3.3.0.  I want the first major 
xtick label aligned with the first date that's plotted.  This never 
happens with the value of day below set in the range zero to six.  The 
first major tick label actually occurs as follows.

Day     Label date
0       25/03/2013
1       02/04/2013
2       10/04/2013
3       21/03/2013
4       29/03/2013
5       06/04/2013
6       17/03/2013

What am I doing wrong?

If day is set to seven then no xticks are displayed but labels for 
14/03/2013 and 13/03/2014 are displayed.  I expected a ValueError or 
similar using this number.  Could you explain this behaviour please?

import matplotlib.pyplot as plt
from matplotlib.ticker import FormatStrFormatter, MultipleLocator
from matplotlib.dates import DateFormatter, WeekdayLocator
import datetime

dates = [datetime.date(2013, 3, 14), datetime.date(2014, 3, 13)]
values = [0, 1]
plt.ylabel('Balance')
plt.grid()
ax = plt.subplot(111)
plt.plot_date(dates, values, fmt = 'rx-')
plt.axis(xmin=dates[0], xmax=dates[-1])
day = ?
ax.xaxis.set_major_locator(WeekdayLocator(byweekday=day, interval=4))
ax.xaxis.set_minor_locator(WeekdayLocator(byweekday=day))
ax.xaxis.set_major_formatter(DateFormatter('%d/%m/%y'))
ax.yaxis.set_major_formatter(FormatStrFormatter('£%0.2f'))
ax.yaxis.set_minor_locator(MultipleLocator(5))
plt.setp(plt.gca().get_xticklabels(), rotation = 45, fontsize = 10)
plt.setp(plt.gca().get_yticklabels(), fontsize = 10)
plt.show()

-- 
Cheers.

Mark Lawrence


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_mar
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to