But report: Date axis formatter problem - matplotlib-users - Matplotlib
But report: Date axis formatter problem Community matplotlib-users Jianbao_Tao October 8, 2012, 4:37pm 1 Problem: The autodatelocator and autodateformatter don’t seem to work properly. One, the formatter doesn’t seem to work immediately after being applied to an axis. A manual call to the locator seems necessary. Two, the autodatelocator doesn’t seem to be able to handle view intervals less than 1 second, i.e., the tick labels don’t show digits beyond second.
You can see this by zooming the example figure from the code below to a level shorter than one second. Operating system: OS X 10.8.2 matplotlib version: 1.2.0rc2 I installed matplotlib via: pip install git+[https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev](https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev) Backend: TkAgg, but I don’t think the problem depends on the backend. Code: #--------------------------------- code ----------------------------------------------------- Running in ipython --pylab mode. fig = figure() tsta = num2epoch(date2num(datetime.datetime.now())) tarr = tsta + arange(0, 60*30., 0.01) # half hour, dt = 0.01 sec x = np.array(num2date(epoch2num(tarr))) nt = len(tarr) y = randn(nt) ax = fig.add_subplot(111) ax.plot(x, y) fig.canvas.draw() # Show an overall view of the data locator = mpl.dates.AutoDateLocator() formatter = mpl.dates.AutoDateFormatter(locator) formatter.scaled = { 365.0 : ‘%Y’, : ‘%b %Y’, 1.0 : ‘%b %d’, 1./24. : ‘%H:%M’, 1./24./60. : ‘%M:%S’, 1./24./60./60. : ‘%S’, } ax.get_xaxis().set_major_formatter(formatter) # Won’t work immediately. locator.set_axis(ax.xaxis) # Have to manually make this call and the one below. locator.refresh() # Another manual call. fig.canvas.draw() #------------------------------------ end of code -------------------------------------------------------- Jianbao_Tao October 8, 2012, 4:39pm 2 Bug to the bug report: In the subject, it should be ‘Bug report’, rather than ‘But report’.
Oops Jianbao ··· On Mon, Oct 8, 2012 at 9:37 AM, Jianbao Tao <jianbao.tao@…287…> wrote: Problem: The autodatelocator and autodateformatter don’t seem to work properly. One, the formatter doesn’t seem to work immediately after being applied to an axis. A manual call to the locator seems necessary. Two, the autodatelocator doesn’t seem to be able to handle view intervals less than 1 second, i.e., the tick labels don’t show digits beyond second.
You can see this by zooming the example figure from the code below to a level shorter than one second. Operating system: OS X 10.8.2 matplotlib version: 1.2.0rc2 I installed matplotlib via: pip install git+[https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev](https://github.com/matplotlib/matplotlib.git#egg=matplotlib-dev) Backend: TkAgg, but I don’t think the problem depends on the backend. Code: #--------------------------------- code ----------------------------------------------------- Running in ipython --pylab mode. fig = figure() tsta = num2epoch(date2num(datetime.datetime.now())) tarr = tsta + arange(0, 60*30., 0.01) # half hour, dt = 0.01 sec x = np.array(num2date(epoch2num(tarr))) nt = len(tarr) y = randn(nt) ax = fig.add_subplot(111) ax.plot(x, y) fig.canvas.draw() # Show an overall view of the data locator = mpl.dates.AutoDateLocator() formatter = mpl.dates.AutoDateFormatter(locator) formatter.scaled = { 365.0 : ‘%Y’, : ‘%b %Y’, 1.0 : ‘%b %d’, 1./24. : ‘%H:%M’, 1./24./60. : ‘%M:%S’, 1./24./60./60. : ‘%S’, } ax.get_xaxis().set_major_formatter(formatter) # Won’t work immediately. locator.set_axis(ax.xaxis) # Have to manually make this call and the one below. locator.refresh() # Another manual call. fig.canvas.draw() #------------------------------------ end of code -------------------------------------------------------- Damon_McDougall3 October 8, 2012, 6:47pm 3 I put it on github: Date axis formatter problem · Issue #1343 · matplotlib/matplotlib · GitHub ··· On Mon, Oct 8, 2012 at 4:37 PM, Jianbao Tao < [email protected] ...> wrote: Problem: The autodatelocator and autodateformatter don't seem to work properly.
One, the formatter doesn't seem to work immediately after being applied to an axis. A manual call to the locator seems necessary. Two, the autodatelocator doesn't seem to be able to handle view intervals less than 1 second, i.e., the tick labels don't show digits beyond second. You can see this by zooming the example figure from the code below to a level shorter than one second. 1. Operating system: OS X 10.8.2 2. matplotlib version: 1.2.0rc2 3.
I installed matplotlib via: pip install git+ GitHub - matplotlib/matplotlib: matplotlib: plotting with Python 4. Backend: TkAgg, but I don't think the problem depends on the backend. 5. Code: #--------------------------------- code ----------------------------------------------------- # Running in ipython --pylab mode. fig = figure() tsta = num2epoch(date2num(datetime.datetime.now())) tarr = tsta + arange(0, 60*30., 0.01) # half hour, dt = 0.01 sec x = np.array(num2date(epoch2num(tarr))) nt = len(tarr) y = randn(nt) ax = fig.add_subplot(111) ax.plot(x, y) fig.canvas.draw() # Show an overall view of the data locator = mpl.dates.AutoDateLocator() formatter = mpl.dates.AutoDateFormatter(locator) formatter.scaled = { 365.0 : '%Y', 30. : '%b %Y', 1.0 : '%b %d', 1./24. : '%H:%M', 1./24./60. : '%M:%S', 1./24./60./60. : '%S', } ax.get_xaxis().set_major_formatter(formatter) # Won't work immediately. locator.set_axis(ax.xaxis) # Have to manually make this call and the one below. locator.refresh() # Another manual call. fig.canvas.draw() #------------------------------------ end of code -------------------------------------------------------- -- Damon McDougall http://www.damon-is-a-geek.com B2.39 Mathematics Institute University of Warwick Coventry West Midlands CV4 7AL United Kingdom