-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
matplotlibrc reader cannot handle rcparams with a hash #7089
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
Maybe we should just use json or yaml for the style files? |
not json... and yaml brings in another dependency (but it isn't that On Sun, Sep 11, 2016 at 12:02 PM, Thomas A Caswell <notifications@github.com
|
Comparison of potential options.
Caveats
|
It doesn't look to me like ConfigParser provides facilities for gracefully handling the problem of an inline hash that starts a comment unless it is inside a string. YAML looks like a pretty big hammer. I think I would rather leave the existing restriction against having the hash in a value than introduce a new dependency and a new set of rules for matplotlibrc and style files. |
JSON can not support inline comments On Sun, Sep 11, 2016 at 2:07 PM, Eric Firing notifications@github.com
|
I'm going to make a possibly not so popular but actually serious proposal: if we do decide to change the config format, simply switch to using python source files as style and config formats. Pros: Cons: |
This should also be coordinated with the traitlets work #4762 Afaik the IPython config files are traitlets based |
Why not just make yaml an optional parser for the matplotlibrc reader, if installed? The amount of code to read into the rc system is minimal, and we could integrate them more closely over time if needed. I've already made a basic parser for this type of data for use in a project, it seems to work fine for basic datasets: with open(fn) as f:
style_object = yaml.load(f)
for k,v in style_object.items():
matplotlib.rc(k,**v) ...which reads YAML configuration files as below into matplotlibrc. font:
size: 8
family: [sans-serif]
sans-serif:
- Helvetica Neue
- Helvetica
- Arial
- sans-serif
weight: 200
mathtext:
default: regular
axes:
labelsize: 8
titlesize: 12
facecolor: white
grid: false
edgecolor: black A more bulletproof parser would probably take some effort, but I imagine not much. Happy to submit a pr if it seems like a good plan. |
My personal opinion is that yaml is a far too complex language for any purpose (see e.g. http://stackoverflow.com/questions/3790454/in-yaml-how-do-i-break-a-string-over-multiple-lines). |
and why is having multiple ways to do a multi-line string a bad thing?
There are a few things I don't like about YAML, but that isn't one of them.
…On Sat, Apr 15, 2017 at 5:54 PM, Antony Lee ***@***.***> wrote:
My personal opinion is that yaml is a far too complex language for any
purpose (see e.g. http://stackoverflow.com/questions/3790454/in-yaml-how-
do-i-break-a-string-over-multiple-lines).
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7089 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AARy-HqhfLaHMvLMjbW9ALmS8J0meiffks5rwTypgaJpZM4J57mm>
.
|
This is just an example amongst others of the extreme complexity of the language. For example, would you know whether
is valid yaml? if so, what does it evaluate to? what about
? |
YAML is a pretty standard config language for many projects, and trying to reinvent the wheel when a standard tool can be adapted to the system is unnecessary. @anntzer: we don't have to support the entire feature-set of YAML or handle edge cases for it to be useful nonetheless |
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! |
In #22589 support for quoted strings was introduced, which then allows including a hash. Will close this for now. |
The parser for the
.mplstyle
files is eager when identifying comments. A#
always demarcates the beginning of a comment, therefore it cannot be part of anrcparam
.Reference: #6907 (comment)
The reader function: https://github.com/matplotlib/matplotlib/blob/af16ac8/lib/matplotlib/__init__.py#L1055
Example style file: https://github.com/matplotlib/matplotlib/blob/master/lib/matplotlib/mpl-data/stylelib/classic.mplstyle#L183
The text was updated successfully, but these errors were encountered: