# Buggy code
def _get_xticks(self, convert_period=False):
    index = self.data.index
    is_datetype = index.inferred_type in ("datetime", "date", "datetime64", "time")

    if self.use_index:
        if convert_period and isinstance(index, PeriodIndex):
            index = index.to_timestamp()
            x = index._mpl_repr()
        elif index.is_numeric() or is_datetype:
            """
                Matplotlib supports numeric values or datetime objects as
                xaxis values. Taking LBYL approach here, by the time
                matplotlib raises exception when using non numeric/datetime
                values for xaxis, several actions are already taken by plt.
                """
            x = index._mpl_repr()
        else:
            self._need_to_set_index = True
            x = range(len(index))
    else:
        x = range(len(index))

    return x


# Traceback (RuntimeError)
Exception in Tkinter callback
Traceback (most recent call last):
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 1413, in __call__
return self.func(*args)
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 498, in callit
func(*args)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 254, in idle_draw
self.draw()
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_tkagg.py", line 239, in draw
FigureCanvasAgg.draw(self)
File "/usr/lib/pymodules/python2.7/matplotlib/backends/backend_agg.py", line 421, in draw
self.figure.draw(self.renderer)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/figure.py", line 898, in draw
func(*args)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axes.py", line 1997, in draw
a.draw(renderer)
File "/usr/lib/pymodules/python2.7/matplotlib/artist.py", line 55, in draw_wrapper
draw(artist, renderer, *args, **kwargs)
File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 1041, in draw
ticks_to_draw = self._update_ticks(renderer)
File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 931, in _update_ticks
tick_tups = [ t for t in self.iter_ticks()]
File "/usr/lib/pymodules/python2.7/matplotlib/axis.py", line 878, in iter_ticks
majorLocs = self.major.locator()
File "/usr/lib/pymodules/python2.7/matplotlib/dates.py", line 750, in __call__
return self._locator()
File "/usr/lib/pymodules/python2.7/pandas/tseries/converter.py", line 317, in __call__
(estimate, dmin, dmax, self.MAXTICKS * 2))
RuntimeError: MillisecondLocator estimated to generate 5270400 ticks from 2012-08-01 00:00:00+00:00 to 2012-10-01 00:00:00+00:00: exceeds Locator.MAXTICKS* 2 (2000)

# Fixed code
def _get_xticks(self, convert_period=False):
    index = self.data.index
    is_datetype = index.inferred_type in ("datetime", "date", "datetime64", "time")

    if self.use_index:
        if convert_period and isinstance(index, PeriodIndex):
            index = index.to_timestamp().order()
            x = index._mpl_repr()
        elif index.is_numeric() or is_datetype:
            """
                Matplotlib supports numeric values or datetime objects as
                xaxis values. Taking LBYL approach here, by the time
                matplotlib raises exception when using non numeric/datetime
                values for xaxis, several actions are already taken by plt.
                """
            x = index.order()._mpl_repr()
        else:
            self._need_to_set_index = True
            x = range(len(index))
    else:
        x = range(len(index))

    return x