Skip to content

BUG: fixing tseries plot cursor display, resolves #5453 #7007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 1, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion doc/source/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -450,8 +450,9 @@ Bug Fixes
- Bug in enabling ``subplots=True`` in ``DataFrame.plot`` only has single column raises ``TypeError``, and ``Series.plot`` raises ``AttributeError`` (:issue:`6951`)
- Bug in ``DataFrame.plot`` draws unnecessary axes when enabling ``subplots`` and ``kind=scatter`` (:issue:`6951`)
- Bug in ``read_csv`` from a filesystem with non-utf-8 encoding (:issue:`6807`)
- Bug in ``iloc`` when setting / aligning (:issue:``6766`)
- Bug in ``iloc`` when setting / aligning (:issue:`6766`)
- Bug causing UnicodeEncodeError when get_dummies called with unicode values and a prefix (:issue:`6885`)
- Bug in timeseries-with-frequency plot cursor display (:issue:`5453`)

pandas 0.13.1
-------------
Expand Down
3 changes: 1 addition & 2 deletions pandas/tseries/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ def tsplot(series, plotf, **kwargs):
ax.set_xlim(left, right)

# x and y coord info
tz = series.index.to_datetime().tz
ax.format_coord = lambda t, y : "t = {} y = {:8f}".format(datetime.fromtimestamp(t, tz), y)
ax.format_coord = lambda t, y: "t = {} y = {:8f}".format(Period(ordinal=int(t), freq=ax.freq), y)

return lines

Expand Down
15 changes: 15 additions & 0 deletions pandas/tseries/tests/test_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ def test_get_datevalue(self):
self.assertEqual(get_datevalue('1/1/1987', 'D'),
Period('1987-1-1', 'D').ordinal)

@slow
def test_ts_plot_format_coord(self):
def check_format_of_first_point(ax, expected_string):
first_line = ax.get_lines()[0]
first_x = first_line.get_xdata()[0].ordinal
first_y = first_line.get_ydata()[0]
self.assertEqual(expected_string, ax.format_coord(first_x, first_y))

annual = Series(1, index=date_range('2014-01-01', periods=3, freq='A-DEC'))
check_format_of_first_point(annual.plot(), 't = 2014 y = 1.000000')

# note this is added to the annual plot already in existence, and changes its freq field
daily = Series(1, index=date_range('2014-01-01', periods=3, freq='D'))
check_format_of_first_point(daily.plot(), 't = 2014-01-01 y = 1.000000')

@slow
def test_line_plot_period_series(self):
for s in self.period_ser:
Expand Down