8000 [MRG+1] plot_date() after axhline() doesn't rescale axes by Yasaman-Mah · Pull Request #8205 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[MRG+1] plot_date() after axhline() doesn't rescale axes #8205

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

Closed
wants to merge 12 commits into from
Prev Previous commit
Next Next commit
test case for bug fix 7742
  • Loading branch information
Yasaman-Mah committed Mar 4, 2017
commit 52beee2131efb33bebe28469fac7e9a6ac9d869b
18 changes: 18 additions & 0 deletions lib/matplotlib/tests/test_axes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4972,3 +4972,21 @@ def test_bar_single_height():
ax.bar(range(4), 1)
# Check that a horizontal chart with one width works
ax.bar(0, 1, bottom=range(4), width=1, orientation='horizontal')

def test_datetime_axhline_same_axes():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pep8 checker is probably going to want 2 blank lines between functions

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like you'll also need to trim trailing whitespace:
https://travis-ci.org/matplotlib/matplotlib/jobs/208246492#L1683

# This test was suggested by Paul Hobson (@phobson) regarding issue 7742
# Check when ploting datetime data and horizontal line
# order of plotting doesn't matter.
# axhline() should not change x axis limits.
from datetime import datetime
fig, axs = plt.subplots(2, 1)
xvalues = [datetime(2016, 1, 1, 0, 0, 0), datetime(2016, 1, 2, 0, 0, 0)]
yvalues = [1, 2]

axs[0].plot(xvalues, yvalues)
axs[0].axhline(1.5)

axs[1].axhline(1.5)
axs[1].plot(xvalues, yvalues)

assert (axs[0].get_xlim() == axs[1].get_xlim())
0