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

ENH: Change default Autodatelocator *interval_multiples*#9801

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

Merged
timhoffm merged 1 commit intomatplotlib:masterfromjklymak:fixdateticklocator
Jul 4, 2018

Conversation

jklymak
Copy link
Member

@jklymakjklymak commentedNov 16, 2017
edited
Loading

PR Summary

OK, AutoDateLocator returned "not-nice" tick labels:

old

So like a dummy, I went and tried to implement better ticks that snapped to the tick intervals (10 minutes in this case). Then this morning I reread the code and found that lo-and-behold, it has a flag for this (interval_multiples=False)

I don't see the rationale behind the default beinginterval_multiples=False. Other than that it will break some existing tests, and its a breaking change. The resulting ticks look far better, and are much more amenable to panning. Tick locators are obscure enough that I never use them except in extremis, so expecting normal users to change options in them just to get something that looks somewhat rational is not putting our best foot forward.

new

PR Checklist

  • Regularize day intervals to include first of month
  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak
Copy link
MemberAuthor

As a further suggestion for discussion, I'd also consider changing the interval for 14 days from a strict 14 days to first of month, 15th of month. We could consider regularizing all the daily intervals to be sure they fall on month boundaries.

The above fails the obvious image comparison tests...

@jklymak
Copy link
MemberAuthor

Is their appetite for changing the default formatters as well, particularly for dates:

I'd strip repeated entries. i.e. for "Feb 01", "Feb 08", "Feb 15", I'd strip "Feb" from the second two labels. i.e. only show month name when day == 1. Similarly, only show years when month == 1 (and day==1). That would make tick labels much more compact.

To make that work properly, the rcParams for the date formaters (i.e.rcParams['date.autoformat.day']) may need to change their meaning, so this would be a breaking change, the problem being that we would need to know how to parse the strings to strip information, and allowing the user to input arbitrary formatting information would make that hard.

@tacaswell
Copy link
Member

I am open to this so long as there is clear and easy instructions on how to get old behavior back.

@jklymak
Copy link
MemberAuthor

I'll work on this.

I was also thinking a tutorial on how to label axes would be useful. I think that info is in a bunch of examples all over the place, but not explained systematically.@tacaswell I only hesitate because I keep hearing rumours that you have a documentation plan. If so, I can wait for that, and help contribute to that.

@tacaswell
Copy link
Member

There is a plan to make a plan. In any outcome, the more content we have up front the less we have to write later (even if we re-organize or re-word it a bit).

If matching the current API is too annoying, making a new formatter / locator (but not using them by default yet) is a reasonable course of action as well.

jklymak reacted with thumbs up emoji

@jklymak
Copy link
MemberAuthor

OK, this PR makesinterval_multiples the default. It also changes the tick locator for months to be 1 and 15 if the 14-day locator is called for.

@jklymakjklymak changed the titleWIP: FIX: Change default Autodatelocator *interval_multiples*ENH: Change default Autodatelocator *interval_multiples*Mar 24, 2018
@jklymakjklymakforce-pushed thefixdateticklocator branch 2 times, most recently frombe9c155 to3356826CompareMarch 25, 2018 04:12
byranges[i] = self._byranges[i][::interval]
if i == 2 and interval == 14:
# special case for monthday: Just tick 1 and 15:
byranges[i] = range(1, 16, 14)
Copy link
Member

Choose a reason for hiding this comment

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

Could this not simply be [1, 15] to make it more clear?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yep!

@@ -319,7 +319,8 @@ def test_empty_date_with_year_formatter():

def test_auto_date_locator():
def _create_auto_date_locator(date1, date2):
locator = mdates.AutoDateLocator()
# we prob. should eventually have a test w/ interval_multiples=True
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this comment is out of date.

jklymak reacted with thumbs up emoji
@@ -13,12 +13,12 @@
# set this to True. It will download and build a specific version of
# FreeType, and then use that to build the ft2font extension. This
# ensures that test images are exactly reproducible.
#local_freetype =False
local_freetype =True
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks extraneous.

@@ -1338,7 +1341,11 @@ def get_locator(self, dmin, dmax):
self._freq = freq

if self._byranges[i] and self.interval_multiples:
byranges[i] = self._byranges[i][::interval]
print(self._byranges[i])
Copy link
Contributor

Choose a reason for hiding this comment

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

print() needs to go before merging.

@@ -1234,6 +1234,9 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000,
5000, 10000, 20000, 50000, 100000, 200000, 500000,
1000000]}
if interval_multiples:
self.intervald[3] = [1, 2, 4, 7, 14, 21]
Copy link
Member

@efiringefiringJul 3, 2018
edited
Loading

Choose a reason for hiding this comment

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

Instead of[3] do you mean[DAILY]?

@efiring
Copy link
Member

I agree with the basic idea here of using "nice" values by default. It would be good to get this into 3.0.

@jklymakjklymakforce-pushed thefixdateticklocator branch 2 times, most recently fromb755888 to44c0bbbCompareJuly 3, 2018 03:16
@jklymak
Copy link
MemberAuthor

Reviews addressed, squashed and rebased, API note added (that may need CI to test if it rendered correctly).

Copy link
Member

@efiringefiring left a comment

Choose a reason for hiding this comment

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

Looks good.

@@ -1234,6 +1234,9 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
MICROSECONDLY: [1, 2, 5, 10, 20, 50, 100, 200, 500, 1000, 2000,
5000, 10000, 20000, 50000, 100000, 200000, 500000,
1000000]}
if interval_multiples:
self.intervald[DAILY] = [1, 2, 4, 7, 14, 21]
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps just curiosity, but why have this substitution of 4 for 3 in this case, and not in general? And isn't 21 a rather strange option? It is inconsistent with the docstring.

Copy link
Member

Choose a reason for hiding this comment

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

To clarify, the 21 option is present in the current code as well as in the line cited above, so the inconsistency predates your PR.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yeah, I don't know why the 21 is in there. I left it in as possibly some weird edge case, but I don't see how it'd happen.

3 vs 4?

3: 1, 4,..., 28, 31, 1
4: 1, 5, ... 25, 29, 1

So except for Feb leap years it avoids an awkward cross-month transition.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

added a couple of comments...

@jklymak
Copy link
MemberAuthor

This is ready for a second review.... Relatively simple change that I think makes the date locators much better...

@jklymakjklymakforce-pushed thefixdateticklocator branch 2 times, most recently from1e609db to7c994b8CompareJuly 3, 2018 23:29
Also make monthly byranges be 1 and 15
@jklymak
Copy link
MemberAuthor

squashed...

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

@efiringefiringefiring approved these changes

@dopplershiftdopplershiftdopplershift left review comments

@timhoffmtimhoffmtimhoffm approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.0.0
Development

Successfully merging this pull request may close these issues.

8 participants
@jklymak@tacaswell@efiring@dopplershift@timhoffm@QuLogic@dstansby@afvincent

[8]ページ先頭

©2009-2025 Movatter.jp