Sadly no :(  I want the day of the month that I'm processing *OR* the 
last day.  The worst case for this is obviously the 31st of each month. 
  The rrule code I've given provides exactly that.  When transferred to 
mpl that doesn't work.

On 04/04/2013 17:31, Phil Elson wrote:
> Hi Mark,
>
> Thanks for persevering :-)
>
> What is it you want to achieve? Is it that you just want the last day of
> each month as the located value?
>
> Changing your locator to:
>
> ax.xaxis.set_major_locator(MonthLocator(bymonthday = -1))
>
> Seems to do the trick for me (I've never looked at the mpl date magic,
> so I can give no guarantees).
>
> HTH,
>
>
> On 4 April 2013 17:18, Mark Lawrence
> <breamore...@yahoo.co.uk
> <mailto:breamore...@yahoo.co.uk>> wrote:
>
>     On 01/04/2013 14:48, Mark Lawrence wrote:
>      > On 29/03/2013 15:49, Mark Lawrence wrote:
>      >> Hi all,
>      >>
>      >>    From http://labix.org/python-dateutil
>      >>
>      >> "To generate a rrule for the use case of "a date on the
>     specified day of
>      >> the month, unless it is beyond the end of month, in which case
>     it will
>      >> be the last day of the month" use the following:
>      >>
>      >> rrule(MONTHLY, bymonthday=(some_day, -1), bysetpos=1)
>      >>
>      >> This will generate a value for every calendar month regardless
>     of the
>      >> day of the month it is started from."
>      >>
>      >> Using bymonthday with MonthLocator gives ticks on the day given
>     and the
>      >> last day of the month, which looks extremely ugly.  Code below
>     demonstrates.
>      >>
>      >> from dateutil.rrule import *
>      >> import datetime
>      >> import matplotlib.pyplot as plt
>      >> from matplotlib.ticker import FormatStrFormatter, MultipleLocator
>      >> from matplotlib.dates import DateFormatter, MonthLocator, DayLocator
>      >>
>      >> start = datetime.date(2013, 3, 29)
>      >> until = datetime.date(2014, 3, 29)
>      >> dates = rrule(MONTHLY, bymonthday=(29, -1), bysetpos=1, until=until)
>      >> for d in dates:print(d)
>      >>
>      >> dates = [start, until]
>      >> values = [0, 1]
>      >> plt.ylabel('Balance')
>      >> plt.grid()
>      >> ax = plt.subplot(111)
>      >> plt.plot_date(dates, values, fmt = 'rx-')
>      >> ax.xaxis.set_major_locator(MonthLocator(bymonthday =
>     (dates[0].day, -1)))
>      >> 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.axis(xmin=dates[0], xmax=dates[-1])
>      >> plt.setp(plt.gca().get_xticklabels(), rotation = 45, fontsize = 10)
>      >> plt.setp(plt.gca().get_yticklabels(), fontsize = 10)
>      >> plt.show()
>      >>
>      >
>      > Seems an apt date to realise that I didn't say much :(
>      >
>      > Assuming that I'm correct would you like an issue raised on the bug
>      > tracker?  If not please correct the mistake I've made, presumably in
>      > reading the docs, which I think are excellent by the way.
>      >
>
>     Anybody?
>
>     --
>     If you're using GoogleCrap™ please read this
>     http://wiki.python.org/moin/GoogleGroupsPython.
>


-- 
If you're using GoogleCrap™ please read this 
http://wiki.python.org/moin/GoogleGroupsPython.

Mark Lawrence


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to