-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlib cutsom style sheet: format dates with new line character #15813
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
This is currently not possible because the parser interprets values as literal strings and thus the backslash is an actual backslash.
One could do We could however optionally allow string quotes |
That proposal seems reasonable to me |
I don't think this keeps backcompat? I'd say the breakage is unlikely to matter in practice, but both adding support for quotes and adding support for escapes break backcompat to similar extents... Perhaps a better solution would be to just use a different syntax to mark "new" entries, e.g.
i.e. the equals sign (rather than colon) says that what comes after is a python literal (which we should just load using |
Theoretically, it's backward compatible, but only if somebody had used string-quoting before and meaning the quotes literally. The likelyhood lf that is small, and I'd be willing to risk that. Since we will only parse escapes in quotes the breakage probability of that is ɛ². I'm not convinced of making a semantic difference with I'd also be open towards making the config YAML, which AFAICS the current config is a subset of (PyYAML has become active again for what it's worth). |
If we choose to move to yaml (ugh) or python, the easiest is likely to just make the config files |
This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help! |
Bug report
Bug summary
In my custom matplotlib style sheet, I want to format the dates in such a way that includes a new line character, i.e.,
%b %d\n%H:%M
. But matplotlib will not recognize the new line character and instead prints\n
as text on my figure.More details here: https://stackoverflow.com/questions/59144140/matplotlib-cutsom-style-sheet-format-dates-with-new-line-character?noredirect=1#comment104516325_59144140
Code for reproduction
In my
my_style.mplstyle
file, I have this formatting instruction for the dates (note the new line character):When I load the style sheet and make a plot with dates on the x axis, it displays the \n as text rather than recognizing it as a new line character.
Actual outcome
Expected outcome
I can get the desired outcome if I use the manual method to change the date formats directly in my code, but I would rather avoid repeating these lines of code in all my plotting scripts. That is why I want to use the style sheet to do this.
Matplotlib version
print(matplotlib.get_backend())
): module://ipykernel.pylab.backend_inlineInstalled from conda
The text was updated successfully, but these errors were encountered: