[MRG+1] plot_date() after axhline() doesn't rescale axes#8205
[MRG+1] plot_date() after axhline() doesn't rescale axes#8205Yasaman-Mah wants to merge 12 commits intomatplotlib:masterfrom
Conversation
| # 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(): |
There was a problem hiding this comment.
The pep8 checker is probably going to want 2 blank lines between functions
There was a problem hiding this comment.
Looks like you'll also need to trim trailing whitespace:
https://travis-ci.org/matplotlib/matplotlib/jobs/208246492#L1683
|
Next time, please add a meaningful title to the pull requests. The reference to the ticket should be in in the description of the PR (else it is non clickable). |
Modified axhline() function to save state of ignoring limits and restore after plotting the line
|
This solution will always reset the existing_data_limits so on the following execution |
|
@Shang-Jia This is a preliminary solution, I submitted this pull request to get some feedback from matplotlib team before going on with another solution. |
|
This looks good to me. Thanks for the patch and sorry it took so long to get feedback! |
| trans = self.get_yaxis_transform(which='grid') | ||
| l = mlines.Line2D([xmin, xmax], [y, y], transform=trans, **kwargs) | ||
| self.add_line(l) | ||
| self.ignore_existing_data_limits = True |
There was a problem hiding this comment.
Can you add a symmetric change to axvline ?
There was a problem hiding this comment.
I have made a similar change to axvline. Please see my comment below before approving the changes.
|
@Yasaman-Mah It's good you pointed that out. However I still think that this PR is a useful contribution and should be merged. This PR fixes #7742 (which produces clearly wrong output), and although it does introduce a side effect, the side effect is not "wrong output", but only slightly inconsistent for a certain specific order of input. And as you pointed out, it would require MUCH more work to fix this inconsistency, because introducing two symmetric flags "ignore_y_limits" and "ignore_x_limits" is a significant architectural change. Hence I would ask @NelleV @tacaswell to review this PR again. Can we go ahead with this fix? |
|
What are dates (which are just input with units) behaving differently than plain numbers? I am still not sure I understand what the The code and the figure above seem out of sync with each other, but I would not call that a 'side effect'. IT looks like the bug from #7742 (order dependent limits) has just been moved to different (and probably more common) case. |
tacaswell
left a comment
There was a problem hiding this comment.
Still not sure I understand what is going on here.
Anyone who can may clear this review.
|
Can this PR be resurrected or closed? |
|
I'm closing for now - but feel free to re-open if someone wants to champion this PR. Thanks for the contribution. |

The only reason that plotting axhline first changes behaviour of plotting datetime is that it sets ignore_existing_data_limits to false and then when plotting datetime data, default datetime data limits are taken into consideration.
Unfortunately this fix would affect y data limits too. I think a better solution would be to have two variables ignore_existing_x_limits and ignore_existing_y_limits, but I am not sure if adding more detail and making it slightly more complicated just because of axhline makes sense.
ref #7742