Skip to content

Better choice of axes offset value #5755

Closed

Description

@anntzer

Currently, when setting xlim(1231, 1239), the offset text is "+1.231e3" and the x labels are 0, ..., 8. I would suggest switching this to +1230 and x labels being 1, ..., 9. There is a formatting issue (basically using "%g" instead of "%f"), but I want to concentrate here on the actual value of the offset.

Basically, I think a reasonable algorithm for the choice of the offset value is the following:
(1) if xmin and xmax have the same number of digits: use the longest common prefix of their string representations, padded by zeros (e.g. xyzabc .. xyzdef => xyz000).
(2) if they don't have the same number of digits (e.g. 9995 .. 10005), I see two possibilities: either fall back to using 9995 as base offset, or use 10000 as base offset in which case the x labels will go from -5 to +5. I tend to think the second option is better but it is true that negative labels can look weird.
(3) note that using negative labels is also an option in case (1) if the number of zeros in the padding is "large" relative to the x range, e.g. 12399995 .. 12400005: it may be better to use 12400000 as base offset and have x labels from -5 to +5 rather than 12300000 as base offset and have x labels from 99995 to 100005.

Thoughts?

Related to #4445, #4451, #5738.

Activity

  1. mdboom commented on Dec 29, 2015

    @mdboom
    Member

    This is a long-standing problem, and as you point out in #5738 is now going to be much more prevalent.

    As for thoughts, I guess it might be useful to make a draft PR that we could all kick at and see how it helps in various contexts.

  2. tacaswell commented on Jan 1, 2016

    @tacaswell
    Member

    Note of promise of test against #5780

  3. modified the milestones: , on Jan 1, 2016
  4. added a commit that references this issue on Jan 27, 2016
  5. added a commit that references this issue on Feb 18, 2016
  6. added a commit that references this issue on May 2, 2016
  7. anntzer commented on May 11, 2016

    @anntzer
    ContributorAuthor

    Closed by #5785.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions