Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Reduce AutoDateFormatter precision when possible#4809

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

matthijskooijman
Copy link

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:#4808

Previously, the AutoDateFormatter would choose a format with second ormicrosecond precision, even when the ticks were significantly coarserthan that. The resulting extra precision looks weird and can clutter thedisplay (especially with the long microsecond display).This commit changes the default scale to format dictionary, which nowworks 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 arehours apart, since then it won't be immediately clear that a time is beingdisplayed. Adding the (technically superfluous) :00 for the minutes shouldmake it immediately obvious that a time is being displayed, which is why theminute precision should also be used when the ticks are hours apart.While updating the documentation for this change, it was also changed to usesymbolic constants instead of hardcoded numbers. This should make it more clearwhat the intention is.Closes:matplotlib#4808
@matthijskooijman
Copy link
Author

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.

1.0 : '%b %d %Y',
1. / HOURS_PER_DAY : '%H:%M',
1. / SEC_PER_DAY : '%H:%M:%S',
1. / MUSECONDS_PER_DAY : '%H:%M:%S.%f'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This part is a doc-string, so perhaps it doesn't make sense to use the global variables here?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I would say it makes the documentation more clear like this? Also, expanding MUSECONDS_PER_DAY would result in1. / (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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fair enough. I'll let others weigh in with their preference.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

I think the globals as much more readable.

@tacaswelltacaswell added this to theColor overhaul milestoneJul 28, 2015
@mdboommdboom modified the milestones:Color overhaul,next major release (2.0)Oct 8, 2015
tacaswell added a commit to tacaswell/matplotlib that referenced this pull requestNov 8, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
@tacaswelltacaswell self-assigned thisNov 8, 2015
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 11, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 16, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 16, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 17, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 23, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 25, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 27, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestNov 27, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 14, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 14, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
@mdboom
Copy link
Member

Would it make sense to just combine this with#5445,@tacaswell?

mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 14, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 17, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 31, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
mdboom pushed a commit to mdboom/matplotlib that referenced this pull requestDec 31, 2015
 - Use ISO complient formats by default - aded extra level of scale (seconds) - add rcparams for all of these stringsclosesmatplotlib#4808closesmatplotlib#4809closesmatplotlib#5086
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees

@tacaswelltacaswell

Projects
None yet
Milestone
v2.0.0
Development

Successfully merging this pull request may close these issues.

4 participants
@matthijskooijman@mdboom@tacaswell@WeatherGod

[8]ページ先頭

©2009-2025 Movatter.jp