From: Brian Z. <br...@gm...> - 2009-04-09 01:47:36
|
On Wed, Apr 8, 2009 at 7:33 AM, Ryan May <rm...@gm...> wrote: > > import matplotlib.ticker as mticker > > def minsec(sec, unused): > minutes = sec // 60 > sec = sec - minutes * 60 > return '%d:%02d' % (minutes, sec) > > locator = mticker.MultipleLocator(60) > formatter = mticker.FuncFormatter(minsec) > > Ryan > > This is exactly what I was looking for...thank you! With this example (and the docs) I finally understand how the Locator and Formatter classes work. Now, I just can do this: locator = mticker.MultipleLocator(60) formatter = mticker.FuncFormatter(lambda x, y: '%02d:%02d' % divmod(x, 60)) self.ax.xaxis.set_major_locator(locator) self.ax.xaxis.set_major_formatter(formatter) Thanks again, BZ |