FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

misplaced spines in dates plot · Issue #7138 · matplotlib/matplotlib · GitHub

Repository navigation

misplaced spines in dates plot #7138

Closed
Closed

Description

Noticed while investigating the test failure in #7123.

from matplotlib import dates; from datetime import *
plt.plot([datetime(1990, 1, 1), datetime(1990, 1, 1) + timedelta(microseconds=1500)], [0, 0])
plt.show()

1.5.3:

2.0b4:

Note how the horizontal spines are shifted in 2.0b4.

Activity

  1. added this to the milestone on Sep 19, 2016
  2. WeatherGod commented on Sep 19, 2016

    Member

    wow, that's a doozy. does this still happen in 2.0b4 with mpl.use('classic')? If so, then that image could be use for direct comparison with the 1.5 image to figure out the exact differences (did the y-spine or the x-spine shift?)

  3. Kojoley commented on Sep 19, 2016

    Member

    matplotlib.style.use('classic') does not help, v2.0.0b1-v2.0.0b4 are affected.

    did the y-spine or the x-spine shift?

    It is x-spine shift. Open the plot, make the window wide and then slowly resize it - you will see.

  4. WeatherGod commented on Sep 19, 2016

    Member

    You can't tell if it is an x or y spine shift to the right or left just by looking at one image. It has to be compared to a baseline - hence why classic mode would be helpful here since fonts and other settings have changed that would complicate direct comparisons.

  5. anntzer commented on Sep 19, 2016

    ContributorAuthor

    It does not happen in classic mode for me.

  6. QuLogic commented on Sep 19, 2016

    Member

    If you pan and zoom, the x spine jumps between alignment with the y spine and how it looks here. The y spine does not shift position.

  7. Kojoley commented on Sep 19, 2016

    Member

    It does not happen in classic mode for me.

    I have this

  8. QuLogic commented on Sep 19, 2016

    Member

    It doesn't happen in classic mode with these axes limits for me, but if you pan around enough, it does happen in classic mode.

  9. Kojoley commented on Sep 19, 2016

    Member

    Try to resize the window

  10. QuLogic commented on Sep 19, 2016

    Member

    I can also trigger it in 1.5.2 as well, with careful panning. Sometimes can even save it as well:

  11. modified the milestones: , on Sep 20, 2016
  12. modified the milestones: v3.0, v3.1 on Aug 11, 2018
  13. 4 remaining items

  14. jklymak commented on Aug 7, 2019

    Member

    We have to convert to float at some point. That involves an inherent loss in resolution over a given date range.

    As pointed out numerous times, using matplotlib date plotting on timescales shorter than milliseconds will lead to inaccuracies and the user should just plot as seconds from the start of the day, or some other reference time. I really don’t think there is any advantage to specially handling dates at such a small scale.

  15. anntzer commented on Aug 7, 2019

    ContributorAuthor

    I'm actually fine with saying "we can't do anything about it", but I think if we can't even position plot elements accurately (if spines are at the wrong place it seems likely that other artists will be rendered at the wrong place too) then we should just error out. Or at least reword the warning in #15000 to something stronger: it's not that plotting microseconds at current reference times is "not well supported", it's that the plot may well have nothing to do with your actual data.

  16. jklymak commented on Aug 7, 2019

    Member

    That'd be fine. But we don't error out on other floating point inaccuracies, its just that this one is more unexpected.

    One thing we could do is change the epoch to something more modern, like 1970, or 2000. Most people plotting old dates do not need millisecond accuracy.

  17. jklymak commented on Aug 7, 2019

    Member

    OK, what do you think about an mdates.set_epoch('1970-01-01') or some such? That would allow users who want to set today as the epoch get resolution out to very small numbers. Of course you would need to set the epoch before you start plotting, but that doesn't seem to be an issue to me.

  18. anntzer commented on Aug 7, 2019

    ContributorAuthor

    I guess that may be nice to have.
    OTOH your comment about other floating point inaccuracies not being warned upon also convinced me that this may not be worth overthinking about.

  19. jklymak commented on Aug 7, 2019

    Member

    I did it. It works, down the point the microsecond locator gives up. But... we lose some guard-rails, like matplotlib times can't be less than 1. OTOH, not sure why that's really needed or desirable.

  20. jklymak commented on Aug 7, 2019

    Member

    I guess I'm still somewhat of the opinion that if you are going to go to the trouble of specifying an epoch, you might as well just subtract the epoch from the time and plot as floats yourself, but I could be convinced otherwise.

  21. anntzer commented on Aug 7, 2019

    ContributorAuthor

    Well we can still say "put your epoch to somewhere earlier than any date you're planning to use" and call it a day. We can even make date2num and friends set a global variable "a date conversion has been done" and make set_epoch error out if any date conversion has already been done (so that we don't end up with inconsistent epochs).

    However I certainly also agree we may be overengineering this.

  22. modified the milestones: needs sorting, v3.3.0 on Apr 29, 2020
  23. QuLogic commented on Apr 29, 2020

    Member

    This should be fixed by #15008, assuming you use a recent epoch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL