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

set offset threshold to 4 · Issue #7104 · matplotlib/matplotlib · GitHub

Repository navigation

set offset threshold to 4 #7104

Closed
Closed

Description

Using the code from #7084, ax.set_xlim(1990, 2020) yields

Tried this for some other values and it seems broken for everything except values that follow the form %d*10^n so 10, 20, 300, etc.

Eta this also yields weirdness: ax.plot(range(1990,2020), range(1990,2020))

Activity

  1. changed the title [-]set_xlim only works for values of the form c*10^n[/-] [+]set_xlim only works for values of the form %d10^n[/+] on Sep 13, 2016
  2. efiring commented on Sep 13, 2016

    Member

    Please put in exactly the code snippets that yield the two example images, and elaborate on what it is that looks wrong. I can't tell from what you have here so far.

  3. story645 commented on Sep 13, 2016

    MemberAuthor

    Sorry about that:

    fig, ax = plt.subplots()
    ax.plot(range(1990,2020), range(1990,2020))

    and it's not a range bug, 'cause the following yields the same figure:

    fig, ax = plt.subplots()
    ax.plot(list(range(1990,2020)), list(range(1990, 2020)))

    This is version 2.0.0b3.post2245+g4f559a9

    The issue is that the xticks and xlims aren't mapping to the datavalues, which are between 1990 and 2020. It should look something like this (which I got by manually setting the labels):

  4. changed the title [-]set_xlim only works for values of the form %d10^n[/-] [+]data values mapping to x-values incorrectly[/+] on Sep 13, 2016
  5. changed the title [-]data values mapping to x-values incorrectly[/-] [+]data values mapping to ticks incorrectly[/+] on Sep 13, 2016
  6. efiring commented on Sep 13, 2016

    Member

    I don't see anything wrong, except in your manually-adjusted example. The Formatter is using an offset of 2000, so the tick labels are from 2000 - 10 to 2000 + 20. In many cases like this one doesn't actually want an offset. It can be turned off with rcParams['axes.formatter.useoffset'] = False, or ax.ticklabel_format(useOffset) = False.

  7. LindyBalboa commented on Sep 13, 2016

    Contributor

    As efiring stated, this is relatively standard behavior, albeit rather counterintuitive. I don't know the source code well enough without looking; could there be room for improvement in the default behavior of deciding when to turn on offsetting?

  8. story645 commented on Sep 13, 2016

    MemberAuthor

    I fully fully support changing the default 'cause that offset seems so incredibly arbitrary and like you said, way counterintuitive. I think it looks at base 10 for defaults somehow, since something like ax.plot(range(200,400)) yields ticks between 200 and 400.

    Also, @efiring how come calling ax.set_xlim((1990,2020)) doesn't overwrite the offset?

  9. efiring commented on Sep 13, 2016

    Member

    On 2016/09/13 9:15 AM, hannah wrote:

    Also, @efiring https://github.com/efiring how come calling
    ax.set_xlim((1990,2020)) doesn't overwrite the offset?

    Setting the view limits is independent of the Formatter; the offset
    comes from the Formatter.

  10. story645 commented on Sep 13, 2016

    MemberAuthor

    @efiring I just realized that half my issue is that I didn't read the notation correctly. Why is the default to pitch it to scientific notation for 4 numbers? (What is the cut off?)

  11. efiring commented on Sep 13, 2016

    Member

    On 2016/09/13 9:27 AM, hannah wrote:

    Why is the default to pitch it to scientific notation for 4 numbers?
    (What is the cut off?)

    A non-zero offset is used if it saves at least 2 significant digits in
    the tick labels, according to the comment in
    ScalarFormatter._compute_offset(). There is no API for changing that
    threshold when offsets are used.

    It looks like the offset is always being forced into scientific
    notation. This does seem like a misfeature. Maybe the offset should be
    formatted using the same powerlimits criterion as is used for the tick
    labels.

  12. story645 commented on Sep 13, 2016

    MemberAuthor

    Maybe the offset should be formatted using the same powerlimits criterion as is used for the tick labels.

    I'm 👍 on that.

  13. changed the title [-]data values mapping to ticks incorrectly[/-] [+]tick offset defauolts to scientific notation[/+] on Sep 13, 2016
  14. changed the title [-]tick offset defauolts to scientific notation[/-] [+]tick offset defaults to scientific notation[/+] on Sep 13, 2016
  15. added this to the milestone on Sep 13, 2016
  16. 4 remaining items

  17. efiring commented on Oct 10, 2016

    Member

    @story645 do you see a way out of the impasse here? If not, I think this needs to be booted down the road to v2.1.

  18. anntzer commented on Oct 10, 2016

    Contributor

    There's a relevant discussion of the formatting of the offset value in the first three messages of #5804, FWIW.

  19. tacaswell commented on Oct 10, 2016

    Member

    Lets bump the threshold up to 3 or 4 digits to make years behave better.

    There are enough questions on SO specifically related to this issue with years (and I have seen it go wrong for my co workers) is worth fixing.

  20. anntzer commented on Oct 10, 2016

    Contributor

    Ah, I didn't think about that use case. Seems reasonable to me.

  21. story645 commented on Oct 13, 2016

    MemberAuthor

    @efiring I'm for whatever solution is easy and more user friendly. I support @tacaswell's suggestion of making a hard minimum of 4 digits since years are very common use case, so much so that it's the usecase that triggered my opening this issue.

  22. changed the title [-]tick offset defaults to scientific notation[/-] [+]set offset threshold to 4[/+] on Oct 19, 2016
  23. added
    Difficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Oct 19, 2016
  24. tacaswell commented on Oct 19, 2016

    Member

    https://github.com/matplotlib/matplotlib/blob/v2.x/lib/matplotlib/ticker.py#L693 is the expression that needs to change, someone just needs to understand it enough to make the threshold 4 instead of 2....

  25. efiring commented on Oct 23, 2016

    Member

    In the line below that, I would try changing to this:

     if abs_max // 10 ** oom >= 1000
  26. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Oct 31, 2016
  27. added a commit that references this issue on Oct 31, 2016
    daa5ed6
  28. dopplershift commented on Nov 8, 2016

    Contributor

    Fixed by #7365.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    API: default changesChanges to default behaviorDifficulty: Easyhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesRelease criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL