-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Better choice of axes offset value #5755
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
Milestone
Comments
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. |
This was referenced Dec 30, 2015
Note of promise of test against #5780 |
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Jan 2, 2016
The axis offset text is choosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Jan 2, 2016
The axis offset text is choosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Jan 2, 2016
The axis offset text is chosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Jan 7, 2016
The axis offset text is chosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Jan 27, 2016
The axis offset text is chosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
Feb 18, 2016
The axis offset text is chosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
anntzer
added a commit
to anntzer/matplotlib
that referenced
this issue
May 2, 2016
The axis offset text is chosen as follows: xlims => offsettext 123, 189 => 0 12341, 12349 => 12340 99999.5, 100010.5 => 100000 # (also a test for matplotlib#5780) 99990.5, 100000.5 => 100000 1233999, 1234001 => 1234000 (and the same for negative limits). See matplotlib#5755.
Closed by #5785. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The text was updated successfully, but these errors were encountered: