Reduce AutoDateFormatter precision when possible#4809
Reduce AutoDateFormatter precision when possible#4809matthijskooijman wants to merge 1 commit intomatplotlib:masterfrom
Conversation
Previously, the AutoDateFormatter would choose a format with second or microsecond precision, even when the ticks were significantly coarser than that. The resulting extra precision looks weird and can clutter the display (especially with the long microsecond display). This commit changes the default scale to format dictionary, which now works as follows: - Use microsecond precision when the ticks are less than a second apart - Use second precision when the ticks are seconds apart - Use minute precision when the ticks are minutes or hours apart - Use day-precision, month or year precision when the ticks are days or more apart (unchanged). Note that there is no point in displaying only the hour when the ticks are hours apart, since then it won't be immediately clear that a time is being displayed. Adding the (technically superfluous) :00 for the minutes should make it immediately obvious that a time is being displayed, which is why the minute precision should also be used when the ticks are hours apart. While updating the documentation for this change, it was also changed to use symbolic constants instead of hardcoded numbers. This should make it more clear what the intention is. Closes: matplotlib#4808
|
Note that this pullrequest has not been tested as-is, since I don't have time right now to set up a full matplotlib build from git. I did test the changes backported into 1.4.3, which works as expected. |
There was a problem hiding this comment.
This part is a doc-string, so perhaps it doesn't make sense to use the global variables here?
There was a problem hiding this comment.
I would say it makes the documentation more clear like this? Also, expanding MUSECONDS_PER_DAY would result in 1. / (24 * 60 * 60 * 1000000), which struck me as overly complicated. But I'm happy to change back to numbers if you think that would be better?
There was a problem hiding this comment.
fair enough. I'll let others weigh in with their preference.
There was a problem hiding this comment.
I think the globals as much more readable.
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
|
Would it make sense to just combine this with #5445, @tacaswell? |
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
- Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these strings closes matplotlib#4808 closes matplotlib#4809 closes matplotlib#5086
Previously, the AutoDateFormatter would choose a format with second or
microsecond precision, even when the ticks were significantly coarser
than that. The resulting extra precision looks weird and can clutter the
display (especially with the long microsecond display).
This commit changes the default scale to format dictionary, which now
works as follows:
apart (unchanged).
Note that there is no point in displaying only the hour when the ticks are
hours apart, since then it won't be immediately clear that a time is being
displayed. Adding the (technically superfluous) :00 for the minutes should
make it immediately obvious that a time is being displayed, which is why the
minute precision should also be used when the ticks are hours apart.
While updating the documentation for this change, it was also changed to use
symbolic constants instead of hardcoded numbers. This should make it more clear
what the intention is.
Closes: #4808