-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: Redundant month in ConciseDateFormatter offset text when it displays days and months #24982
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
Comments
According to the milestone, the |
This is expected behaviour - if you had another month in your date range, I think it would change to just showing the year. If you want to change the formats for the different levels there is an offset_formats kwarg to It would be hard to argue that we should change the default, because that would require a whole deprecation cycle, which is difficult for kwargs, and I'd say not worth the pain in this case. |
I contemplated this when working on #22871 There a special casing was added for the year and I was thinking about the other cases as well. IIRC it really comes down to what the format strings include and if the first day of the month is hit or not. Although I agree that conceptually, the month should not be in your example, one would simply need another formatter for that, as combining modifiable static formatting and dynamic adaptation of the formatting is not really possible (either we always guess or never guess, sort of, the current solution never guesses). I think that another formatter that prints the ticks at a suitable level and then print all remaining date information in the offset, as long as it is not already in the ticks would be doable though, possibly with an argument for "highest" level to be shown in the offset. (Finally, one could question if it actually should be Mar in the example. It seems like maybe Jan is a more natural choice for offset?) |
The month and year offset always shows up no matter how many months and days you have like in the first image I posted |
Again, this is not a bug, just a disagreement about what the defaults should be. Changing the defaults is a breaking API change, so there would have to be a pretty strong reason to do that song and dance. We did go back and forth a fair bit on what the default labels should be and arrived at this as reasonable. |
You can't use the |
The thing is that you would need to do that at every level. If you plot hours, then you will need to check a day is printed and in that case select a different string. It is not possible to implement it like that, just an Another example: say that you set the tick format for month as So either one goes with a static mechanism (as now) or one can write a fully automatic version. (Or a third version that parses the format strings and then removes any format markers from the offset that are printed in the ticks.) I think we all agree that there are cases where the current defaults are not ideal in all cases (there are no defaults that are ideal in all cases), but one can change the format as required and there are no "surprises". I think this can be kept open as it clearly indicates a need for another formatter that guesses more (and probably is less configurable). |
Actually, what we can do is to change the logic so that if the (Still it will need a deprecation period if we change the default behavior.) |
Yes I think that might work |
Bug summary
When you make a plot with the
ConciseDateFormatter
that shows on the x axis days and months theoffset_string
also shows the month (with the year) which I think is redundant because you only need the yearCode for reproduction
Actual outcome
Expected outcome
Additional information
When the
ConciseDateFormatter
was proposed here you can see the same expected behavior:Operating system
Ubuntu 22.04.1 LTS
Matplotlib Version
3.6.2
Matplotlib Backend
agg
Python version
3.10.6
Jupyter version
No response
Installation
pip
The text was updated successfully, but these errors were encountered: