|
16 | 16 | from pandas.tseries.frequencies import get_period_alias, get_base_alias
|
17 | 17 | from pandas.tseries.offsets import DateOffset
|
18 | 18 |
|
19 |
| -""" |
20 | 19 | try: # mpl optional
|
21 | 20 | import pandas.tseries.converter as conv
|
22 |
| - conv.register() |
| 21 | + conv.register() # needs to override so set_xlim works with str/number |
23 | 22 | except ImportError:
|
24 | 23 | pass
|
25 |
| -""" |
26 | 24 |
|
27 | 25 | def _get_standard_kind(kind):
|
28 | 26 | return {'density': 'kde'}.get(kind, kind)
|
@@ -913,20 +911,6 @@ def _maybe_add_color(self, colors, kwds, style, i):
|
913 | 911 | if style is None or re.match('[a-z]+', style) is None:
|
914 | 912 | kwds['color'] = colors[i % len(colors)]
|
915 | 913 |
|
916 |
| - def _make_formatter_locator(self): |
917 |
| - import pandas.tseries.converter as conv |
918 |
| - index = self.data.index |
919 |
| - if (isinstance(index, DatetimeIndex) or |
920 |
| - index.inferred_type in ('datetime', 'datetime64', 'date')): |
921 |
| - tz = getattr(index, 'tz', None) |
922 |
| - loc = conv.PandasAutoDateLocator(tz=tz) |
923 |
| - fmt = conv.PandasAutoDateFormatter(loc, tz=tz) |
924 |
| - return fmt, loc |
925 |
| - if index.inferred_type == 'time': |
926 |
| - loc = conv.AutoLocator() |
927 |
| - fmt = conv.TimeFormatter(loc) |
928 |
| - return fmt, loc |
929 |
| - |
930 | 914 | def _make_plot(self):
|
931 | 915 | import pandas.tseries.plotting as tsplot
|
932 | 916 | # this is slightly deceptive
|
@@ -969,9 +953,7 @@ def _make_plot(self):
|
969 | 953 | ax.grid(self.grid)
|
970 | 954 |
|
971 | 955 | if self._is_datetype():
|
972 |
| - _maybe_format_dateaxis(ax, *self._make_formatter_locator()) |
973 | 956 | left, right = _get_xlim(lines)
|
974 |
| - print 'xlim: ', left, right |
975 | 957 | ax.set_xlim(left, right)
|
976 | 958 |
|
977 | 959 | self._make_legend(lines, labels)
|
@@ -1937,22 +1919,22 @@ def on_right(i):
|
1937 | 1919 |
|
1938 | 1920 | return fig, axes
|
1939 | 1921 |
|
1940 |
| -def _maybe_format_dateaxis(ax, formatter, locator): |
1941 |
| - from matplotlib import pylab |
1942 |
| - ax.xaxis.set_major_locator(locator) |
1943 |
| - ax.xaxis.set_major_formatter(formatter) |
1944 |
| - pylab.draw_if_interactive() |
1945 |
| - |
1946 |
| - |
1947 | 1922 | def _get_xlim(lines):
|
1948 | 1923 | import pandas.tseries.converter as conv
|
1949 | 1924 | left, right = np.inf, -np.inf
|
1950 | 1925 | for l in lines:
|
1951 | 1926 | x = l.get_xdata()
|
1952 |
| - left = min(conv._dt_to_float_ordinal(x[0]), left) |
1953 |
| - right = max(conv._dt_to_float_ordinal(x[-1]), right) |
| 1927 | + left = min(_maybe_convert_date(x[0]), left) |
| 1928 | + right = max(_maybe_convert_date(x[-1]), right) |
1954 | 1929 | return left, right
|
1955 | 1930 |
|
| 1931 | +def _maybe_convert_date(x): |
| 1932 | + if not com.is_integer(x): |
| 1933 | + conv_func = conv._dt_to_float_ordinal |
| 1934 | + if isinstance(x, datetime.time): |
| 1935 | + conv_func = conv._to_ordinalf |
| 1936 | + x = conv_func(x) |
| 1937 | + return x |
1956 | 1938 |
|
1957 | 1939 | if __name__ == '__main__':
|
1958 | 1940 | # import pandas.rpy.common as com
|
|
0 commit comments